##// END OF EJS Templates
Added childContainer service to container services, ServiceContaier is destroyable, fixed browser Uuid version
Added childContainer service to container services, ServiceContaier is destroyable, fixed browser Uuid version

File last commit:

r115:691199f665e0 ioc ts support
r146:f3f5c56d3b3e v1.4.0-rc5 default
Show More
EventProvider.ts
41 lines | 1.1 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / EventProvider.ts
import { IDestroyable } from "./interfaces";
import { Observable } from "./Observable";
/**
* Event proviers are used to produce events, throug this object you can feed
* the Observable with input events. Once the EventProvider is destroyed the
* bound obsevable is disconnected and marked as 'done'.
*/
export class EventProvider<T> implements IDestroyable {
_observable: Observable<T> | undefined;
_next: ((evt: T) => void) | undefined;
_done: (() => void) | undefined;
constructor() {
this._observable = new Observable<T>((next, _error, done) => {
this._next = next;
this._done = done;
});
}
destroy(): void {
if (this._observable) {
// break all references
this._observable = undefined;
this._next = undefined;
this._done = undefined;
}
}
post(event: T) {
return this._next && this._next(event);
}
getObservable() {
if (!this._observable)
throw new Error("The object is destroyed");
return this._observable;
}
}