##// END OF EJS Templates
added provided and configure methods to the fluent container configuration, added applyConfig method to the container
added provided and configure methods to the fluent container configuration, added applyConfig method to the container

File last commit:

r115:691199f665e0 ioc ts support
r142:be7edf08a115 v1.4.0-rc3 default
Show More
Cancellation.ts
83 lines | 1.9 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / Cancellation.ts
cin
changed the project structure
r49 import { ICancellation, IDestroyable } from "./interfaces";
cin
Added safe.delay...
r76 import { argumentNotNull, destroyed } from "./safe";
cin
changed the project structure
r49
export class Cancellation implements ICancellation {
private _reason: any;
cin
corrected code to support ts strict mode...
r115 private _cbs: Array<(e: any) => void> | undefined;
cin
changed the project structure
r49
cin
Added safe.delay...
r76 constructor(action: (cancel: (e?: any) => void) => void) {
cin
changed the project structure
r49 argumentNotNull(action, "action");
action(this._cancel.bind(this));
}
isSupported(): boolean {
return true;
}
throwIfRequested(): void {
if (this._reason)
throw this._reason;
}
isRequested(): boolean {
return !!this._reason;
}
register(cb: (e: any) => void): IDestroyable {
argumentNotNull(cb, "cb");
if (this._reason) {
cb(this._reason);
return destroyed;
} else {
if (!this._cbs)
this._cbs = [cb];
else
this._cbs.push(cb);
const me = this;
return {
destroy() {
me._unregister(cb);
}
};
}
}
cin
corrected code to support ts strict mode...
r115 private _unregister(cb: any) {
cin
changed the project structure
r49 if (this._cbs) {
const i = this._cbs.indexOf(cb);
if (i >= 0)
this._cbs.splice(i, 1);
}
}
cin
corrected code to support ts strict mode...
r115 private _cancel(reason: any) {
cin
changed the project structure
r49 if (this._reason)
return;
this._reason = (reason = reason || new Error("Operation cancelled"));
if (this._cbs) {
this._cbs.forEach(cb => cb(reason));
cin
corrected code to support ts strict mode...
r115 this._cbs = undefined;
cin
changed the project structure
r49 }
}
static readonly none: ICancellation = {
isSupported(): boolean {
return false;
},
throwIfRequested(): void {
},
isRequested(): boolean {
return false;
},
register(_cb: (e: any) => void): IDestroyable {
return destroyed;
}
};
}