mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Add forward to Event
This commit is contained in:
@@ -615,6 +615,22 @@ export namespace Event {
|
||||
return result.event;
|
||||
}
|
||||
|
||||
/**
|
||||
* A convenience function for forwarding an event to another emitter which
|
||||
* improves readability.allows Event.forward(event, emitter) instead of `event(e => emitter.fire(e))`.
|
||||
* @param from The event to forward.
|
||||
* @param to The emitter to forward the event to.
|
||||
* @example
|
||||
* Event.forward(event, emitter);
|
||||
* // equivalent to
|
||||
* event(e => emitter.fire(e));
|
||||
* // equivalent to
|
||||
* event(emitter.fire, emitter);
|
||||
*/
|
||||
export function forward<T>(from: Event<T>, to: Emitter<T>): IDisposable {
|
||||
return from(e => to.fire(e));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a listener to an event and calls the listener immediately with undefined as the event object.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user