subscribeNotices()function
subscribeNotices(callback: (message: ReactNode, status?: Status | undefined) => void, el: EventTarget = window): () => void
| Param | Type | |
|---|---|---|
callback | (message: ReactNode, status?: Statusundefined) => void | Called with the message and status each time a notice event fires. required |
el | EventTarget | Element to subscribe on (defaults to window). Defaults to window |
| Return | |
|---|---|
() => void | An unsubscribe function that removes the listener. |
Subscribe to notice events on an element and call a callback when they happen.
- Stops propagation so the notice is not handled again by a higher subscriber.
Examples
const stop = subscribeNotices((message, status) => show(message, status));