SipaEvents
SipaEvents
SipaEvents
Provides adding and triggering customized events.
new SipaEvents(...valid_event_names)
| Param | Type | Description | 
|---|---|---|
| ...valid_event_names | string | define the available event names | 
Example
// To add to a class, the suggested pattern is
 events() {
        return this._events ??= new SipaEvents(['click','delete','update']);
 }
sipaEvents._event_registry : Object.<string, Array.<function()>>
Here we store registered events
sipaEvents.subscribe(event_name, callback)
Kind: instance method of SipaEvents  
| Param | Type | Description | 
|---|---|---|
| event_name | string | must be one of this._valid_event_names | 
| callback | function | 
sipaEvents.unsubscribe(event_name, callback)
Kind: instance method of SipaEvents  
| Param | Type | 
|---|---|
| event_name | string | 
| callback | function | 
sipaEvents.unsubscribeAll(event_name)
Unsubscribe all subscriptions of the given event name.
Usually you should only use the unsubscribe() method to unsubscribe. Use this method with care!
| Param | 
|---|
| event_name | 
sipaEvents.trigger(event_name, msg, options)
Calls all registered events of event_name
| Param | Type | Default | Description | 
|---|---|---|---|
| event_name | String | ||
| msg | Array.<any> | params to pass to the created event function | |
| options | Object | ||
| options.validate | boolean | true | validate the given event name to be valid | 
sipaEvents.reset()
Unsubscribes all subscriptions of any event
sipaEvents.createEvents(...event_names)
Extend valid event names dynamically
| Param | Type | 
|---|---|
| ...event_names | string | 
sipaEvents.deleteEvents(...event_names)
Delete valid event names dynamically
| Param | Type | 
|---|---|
| ...event_names | string |