Implemented a mechanism to subscribe to events under different contexts.
Implemented the ability to dispatch events to specific contexts based on the event name pattern.
Introduced validation to ensure that event names follow the pattern "contextName:EventName".
// Example Usage
const context = Context.events();
const handler = (event) => console.log(event);
// Subscribing to events under different contexts
context.subscribe('Context-A:SIGNUP', handler);
context.subscribe('Context-B:SIGNUP', handler);
context.subscribe('Context-C:SIGNUP', handler);
context.subscribe('Context-B:NOTIFY', handler);
context.subscribe('Context-B:SEND-EMAIL', handler);
// Dispatching events to specific contexts
// Dispatches the SIGNUP event to Context-B
context.dispatchEvent('Context-B:SIGNUP');
// Dispatches the SIGNUP event to all contexts
context.dispatchEvent('*:SIGNUP');
// Dispatches all events to all contexts. Not recommended
context.dispatchEvent('*:*');
// Dispatches all events under Context-B
context.dispatchEvent('Context-B:*');
Updates
[1.22.0] - 2024-04-13
Features Added #134
Implementation Details: