##// END OF EJS Templates
Added tag v1.4.6 for changeset 3969a8fb8049
Added tag v1.4.6 for changeset 3969a8fb8049

File last commit:

r172:3969a8fb8049 release v1.4.6 default
r173:3843ec3ca8f8 default
Show More
AsyncComponent.ts
38 lines | 1.2 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / components / AsyncComponent.ts
cin
changed the project structure
r49 import { Cancellation } from "../Cancellation";
cin
Added Cancellation.combine(...tokens) method to combine multiple cancellation...
r170 import { IAsyncComponent, ICancellation, ICancellable } from "../interfaces";
cin
changed the project structure
r49
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
cin
text/format refactoring
r54 const inner = new Cancellation(cancel => {
cin
changed the project structure
r49 this._cancel = cancel;
});
cin
text/format refactoring
r54 const guard = async () => {
cin
changed the project structure
r49 try {
cin
Added CancelledError, fixed lint warnings
r172 const combined = Cancellation.combine(ct, inner);
const result = await op(combined);
combined.throwIfRequested();
return result;
cin
changed the project structure
r49 } finally {
// after the operation is complete we need to cleanup the
// resources
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 }