Put in order · JavaScript and React course · Module 15: Patterns and Architecture
EventBus Implementation Steps
Arrange the steps for implementing Event-Driven Architecture in React:
Items to put in order
- Create a useEventListener hook with cleanup in useEffect
- Create a useEventEmitter hook returning an emit function
- Create a singleton eventBus = new EventBus()
- Use the hooks in publisher and subscriber components
- Create an EventBus class with on() and emit() methods
You can check the correct answer by solving this task in the CodeWorlds game.