##// END OF EJS Templates
corrected code to support ts strict mode...
corrected code to support ts strict mode safe.ts - more tight typings - added notImplemented stub function - added fork funtion - added keys function (like Object.keys but extracts keys type) - added isKeyof typeguard - added 'primitive' union type added EventProvider for the observable

File last commit:

r115:691199f665e0 ioc ts support
r115:691199f665e0 ioc ts support
Show More
AsyncComponent.ts
40 lines | 1.2 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / components / AsyncComponent.ts
cin
changed the project structure
r49 import { Cancellation } from "../Cancellation";
import { IAsyncComponent, ICancellation, ICancellable, IDestroyable } from "../interfaces";
import { destroy } from "../safe";
export class AsyncComponent implements IAsyncComponent, ICancellable {
cin
corrected code to support ts strict mode...
r115 _cancel: ((e: any) => void) | undefined;
cin
changed the project structure
r49
_completion: Promise<void> = Promise.resolve();
cin
text/format refactoring
r54 getCompletion() { return this._completion; }
cin
changed the project structure
r49
runOperation(op: (ct: ICancellation) => any, ct: ICancellation = Cancellation.none) {
// create inner cancellation bound to the passed cancellation token
let h: IDestroyable;
cin
text/format refactoring
r54 const inner = new Cancellation(cancel => {
cin
changed the project structure
r49
this._cancel = cancel;
h = ct.register(cancel);
});
// TODO create cancellation source here
cin
text/format refactoring
r54 const guard = async () => {
cin
changed the project structure
r49 try {
await op(inner);
} finally {
// after the operation is complete we need to cleanup the
// resources
destroy(h);
cin
corrected code to support ts strict mode...
r115 this._cancel = undefined;
cin
changed the project structure
r49 }
cin
text/format refactoring
r54 };
cin
changed the project structure
r49
return this._completion = guard();
}
cin
working on support commonjs modules format
r59 cancel(reason: any) {
cin
changed the project structure
r49 if (this._cancel)
this._cancel(reason);
}
cin
text/format refactoring
r54 }