@aappddeevv/dynamics-client-ui
Version:
## What is it? A library to help you create great dynamics applications.
24 lines (23 loc) • 899 B
TypeScript
/**
* Simple Dynamics event bus. Designed to be used for simple needs
* and attached to a window that sub-iframes can access easily so their
* WebResources can listen for events from across a Dynamics form
* e.g. a grid select needs.
*/
/** Subscriber takes a simple event object differentiated by type. */
export declare type Subscriber = ({type: string}) => void;
/** A thunk that unsubscribes when called. */
export declare type Cancellable = () => void;
/** Small pubsub, synchronous dispatch. */
export declare class EventBus {
private subscribers;
unsubscribe(key: any): void;
/** Subscriber is just a thunk. Thunk returned unsubscribes. */
subscribe(subscriber: Subscriber): () => void;
/** Dispatch an event. All subscribers get all events like redux. */
dispatch(event: any): void;
}
export default EventBus;
export interface Window {
eventbus: EventBus;
}