本文整理汇总了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));
});