You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: event-bus to be async to allow for non-blocking callbacks (#106)
* feat: rewrote event-bus to be asynchronous to allow for non-blocking callbacks
BREAKING CHANGE: `subscribe` is now asynchronous and requires `await` before call to `unsubscribe`
* feat: update dependencies
* fix: deps
* ci: update node versions
* feat: wildcard channels
BREAKING CHANGE: wildcard channels now get the original channel
* fix: logs and tests
The EventBus constructor accepts an options object with the following properties:
258
+
259
+
```typescript
260
+
interfaceEventBusOptions {
261
+
/**
262
+
* The logging level for the event bus
263
+
* - 'none': No logging
264
+
* - 'error': Only log errors (default)
265
+
* - 'warn': Log warnings and errors
266
+
* - 'info': Log everything
267
+
*/
268
+
logLevel?:'none'|'error'|'warn'|'info';
269
+
}
270
+
```
271
+
231
272
### Register
232
273
233
274
Register a schema for the specified event type and equality checking on subsequent registers. Subsequent registers must use an equal schema or an error will be thrown.
Note: Subscribe is an async function that returns a Promise with the subscription.
322
+
280
323
Callbacks will be fired when event is published on a subscribed channel with the argument:
281
324
282
325
```typescript
@@ -300,10 +343,10 @@ Callbacks will be fired when event is published on a subscribed channel with the
300
343
301
344
### Publish
302
345
303
-
Publish to event channel with an optional payload triggering all subscription callbacks.
346
+
Publish to event channel with an optional payload triggering all subscription callbacks. Returns a Promise that resolves when all callbacks have completed.
0 commit comments