Skip to main content
grasp.study
Log in
Try it for free
Back to course
👋
Welcome to a Grasp lesson
Create a free account
to keep studying and create your own study path.
Modern JS framework with TypeScript
·
Module 7
Type-Safe Event Bus
1
Type-Safe Event Maps with Mapped Types
Design a type-safe event map interface using mapped types to link event names (strings) to specific payload types.
2
Generic EventBus with Constrained Event Map
Implement an `EventBus` class with a generic type parameter constrained by the event map.
3
Type-Safe Event Emitters with Mapped Types
Implement type-safe `emit` and `on` methods that enforce correct payload types for each event name using key remapping in mapped types.
4
Typed Observables for EventBus Events
Implement a method on the `EventBus` that returns a correctly typed observable for a specific event.
5
Automatic Listener Cleanup with EventBus
Ensure the `EventBus` automatically cleans up its internal listeners when the returned observable is unsubscribed.
Previous module
Pipeable Operators: Error Handling & Completion
Next module
Advanced Testing & RxJS Interoperability