Complex event payloads
You can pass any type as the event payload. If you've got a particular complex, consider creating a dedicated payload type for it. This makes writing listeners a little easier as you can use the type for the parameters.
Examplestsinterface ComplexEventPayload {foobar: {name: string;enabled: boolean;};option: 'a'|'b';}// Creating eventconst complexEvent = new SimpleEvent<ComplexEventPayload>();// Listeningfunction listener(payload: ComplexEventPayload) {// ...}complexEvent.subscribe(listener);// FiringcomplexEvent.dispatch({foobar: {name: 'guest',enabled: true,},option: 'b',});
Examplestsinterface ComplexEventPayload {foobar: {name: string;enabled: boolean;};option: 'a'|'b';}// Creating eventconst complexEvent = new SimpleEvent<ComplexEventPayload>();// Listeningfunction listener(payload: ComplexEventPayload) {// ...}complexEvent.subscribe(listener);// FiringcomplexEvent.dispatch({foobar: {name: 'guest',enabled: true,},option: 'b',});
See events for more information.