Complete the code to show how an event helps services communicate without direct calls.
serviceA.publish([1])Publishing an event like "OrderCreatedEvent" allows services to communicate without direct calls, enabling decoupling.
Complete the code to show how a service listens for an event to react asynchronously.
eventBus.subscribe("OrderCreatedEvent", [1])
Subscribing with a handler function like handleOrderCreated allows reacting to events asynchronously.
Fix the error in the code to properly decouple services using events.
serviceB.processOrder() # Incorrect direct call serviceA.[1](orderData) # Correct event publish
Using publishEvent sends an event instead of a direct call, decoupling services.
Fill both blanks to complete the event-driven communication pattern.
eventBus.[1]("PaymentProcessed", [2])
Subscribing to the "PaymentProcessed" event with handlePayment decouples services.
Fill all three blanks to complete the event-driven service interaction.
serviceA.[1]("UserRegistered", data) serviceB.[2]("UserRegistered", [3])
Service A emits the "UserRegistered" event, and Service B subscribes to it with handleUserRegistration to stay decoupled.