本文整理匯總了TypeScript中@theintern/common.Task類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Task類的具體用法?TypeScript Task怎麽用?TypeScript Task使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Task類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: constructor
constructor(options: HttpChannelOptions) {
super(options);
this._sequence = 1;
this._maxPostSize = options.maxPostSize || 100000;
this._messageBuffer = [];
this._lastRequest = Task.resolve();
}
示例2: spy
const request = spy((path: string, data: any) => {
if (requestHandler) {
return requestHandler(path, data);
}
const result = requestData && requestData[path];
return Task.resolve(result);
});
示例3: _handleError
protected _handleError(error: Error) {
// Make the _ready task a reject to reject future _sendData calls
this._ready = Task.reject(error);
// Reject any open sends
Object.keys(this._sendQueue)
.filter(id => this._sendQueue[id] != null)
.forEach(id => {
this._sendQueue[id]!.reject(error);
this._sendQueue[id] = undefined;
});
}
示例4: download
download(forceDownload = false): CancellablePromise<void> {
if (!forceDownload && this.isDownloaded) {
return Task.resolve();
}
return new Task((resolve, reject) => {
exec(
`npm install --no-save cbt_tunnels@${this.cbtVersion}`,
(error, _stdout, stderr) => {
if (error) {
console.error(stderr);
reject(error);
} else {
resolve();
}
}
);
});
}
示例6: sendJobState
sendJobState(): CancellablePromise<void> {
return Task.resolve();
}
示例7: start
start(): CancellablePromise<void> {
this._state = 'running';
return Task.resolve();
}
示例8: download
download(): CancellablePromise<void> {
return Task.resolve();
}
示例9: spy
const request = spy((path: string) => {
const data = requestData && requestData[path];
return Task.resolve(new MockResponse(data));
});