##// 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:

r134:511bcc634d65 ioc ts support
r142:be7edf08a115 v1.4.0-rc3 default
Show More
AsyncComponent.ts
41 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";
cin
working on fluent configuration, di annotations removed
r134 const noop = () => void (0);
cin
changed the project structure
r49 export class AsyncComponent implements IAsyncComponent, ICancellable {
cin
working on fluent configuration, di annotations removed
r134 _cancel: ((e: any) => void) = noop;
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
working on fluent configuration, di annotations removed
r134 this._cancel = noop;
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
working on fluent configuration, di annotations removed
r134 this._cancel(reason);
cin
changed the project structure
r49 }
cin
text/format refactoring
r54 }