0
0
LLDsystem_design~10 mins

Event-driven design in LLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define an event handler function.

LLD
def handle_event(event):
    if event.type == [1]:
        process_event(event)
Drag options to blanks, or click blank then click option'
Aevent
Bclick
Chandler
Dprocess
Attempts:
3 left
💡 Hint
Common Mistakes
Using the event object itself instead of its type.
Using unrelated words like 'handler' or 'process'.
2fill in blank
medium

Complete the code to publish an event to the event bus.

LLD
event_bus.[1](event)
Drag options to blanks, or click blank then click option'
Apublish
Blisten
Csubscribe
Dhandle
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'subscribe' which is for listening, not sending.
Using 'handle' which is for processing events.
3fill in blank
hard

Fix the error in the event subscription code.

LLD
event_bus.[1](event_type, callback_function)
Drag options to blanks, or click blank then click option'
Ahandle
Bpublish
Csubscribe
Demit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'publish' instead of 'subscribe'.
Using 'emit' which is similar to publish but not for subscription.
4fill in blank
hard

Fill both blanks to create an event-driven loop that waits and processes events.

LLD
while True:
    event = event_queue.[1]()
    if event is not None:
        [2](event)
Drag options to blanks, or click blank then click option'
Aget_event
Bprocess_event
Cpublish
Dsubscribe
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'publish' or 'subscribe' in the loop incorrectly.
Not calling the processing function on the event.
5fill in blank
hard

Fill all three blanks to define an event handler that filters and processes only 'update' events.

LLD
def event_handler(event):
    if event.type == [1]:
        data = event.[2]
        [3](data)
Drag options to blanks, or click blank then click option'
A'update'
Bpayload
Cprocess_update
Dtype
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'type' as a string instead of the attribute name.
Calling the wrong processing function.