Class “Listeners”

Object > Observable > Listeners

Objects of the type Listeners provide methods to manage listeners and trigger events. They encapsulate the tabris event system in a way that is more convenient to use with TypeScript, async/await and RxJS.

Type: Listeners<EventData> extends Observable<EventData>
Generics: EventData: A plain object containing the data to be passed to the listeners in addition to target, type and timeStamp. Must be a subclass of {target: object} and defaults to undefined.
Constructor: public
Singleton: No
Namespace: tabris
Direct subclasses: ChangeListeners
JSX Support: No


new Listeners(target, type)

Parameter Type Description
target object  
type string  



Registers a listener to be notified by new events. Each listener can only be added once. Returns the target object. Instances of Listeners can also be called directly as a function to register a new listener. I.e. widget.onResize(listener); is the same as widget.onResize.addListener(listener); It is also the same as widget.on('resize', listener');, but with better TypeScript support.

Parameter Type Description
listener Function The listener function called with the event object



Notifies the given listener the next time an event is issued, but not afterwards. Returns the target object.

Parameter Type Description
listener Function The listener function called with the event object



Returns a promise that resolves the next time an event is issued. The dispatched event object will be used as the resolved value.

Returns: Promise<EventObject>


Deregisters a listener, it will not be notified of future events. Returns the target object.

Parameter Type Description
listener Function  



Issues a plain event object to all registered listeners with a newly constructed event object.



Issues an event object to all registered listeners. If an uninitialized (not previously issued) instance of EventObject is given as the argument it will be issued directly as-is. Any other type of object (including an already initialized/previously issued event object) will be copied to create a new event object. This allows for simple event re-routing.

Parameter Type Description
eventData EventData Optional.



Like trigger, but returns a promise. The promise will resolve when all asynchronous listeners (if any) have resolved. If none of the listeners are asynchronous (return a promise) this method works just like trigger(). Useful for unit testing.

Parameter Type Description
eventData object Optional.

Returns: Promise</code>



The object that issues the events, e.g. a widget.

Type: object
Settable: No


The event type. This value will be set in the type field of the event object given to the listener. It is the same value used by the on and trigger methods.

Type: string
Settable: No