提交 3bf2a074 编写于 作者: A Alex Dima

Reduce usage of winjs promise progress

上级 5ffd9f50
......@@ -352,7 +352,7 @@ export class Barrier {
constructor() {
this._isOpen = false;
this._promise = new TPromise<boolean>((c, e, p) => {
this._promise = new TPromise<boolean>((c, e) => {
this._completePromise = c;
}, () => {
console.warn('You should really not try to cancel this ready promise!');
......
......@@ -91,7 +91,7 @@ class SimpleWorkerProtocol {
c: null,
e: null
};
let result = new TPromise<any>((c, e, p) => {
let result = new TPromise<any>((c, e) => {
reply.c = c;
reply.e = e;
}, () => {
......@@ -232,7 +232,7 @@ export class SimpleWorkerClient<T> extends Disposable {
loaderConfiguration = (<any>self).requirejs.s.contexts._.config;
}
this._lazyProxy = new TPromise<T>((c, e, p) => {
this._lazyProxy = new TPromise<T>((c, e) => {
lazyProxyFulfill = c;
lazyProxyReject = e;
}, () => { /* no cancel */ });
......@@ -273,7 +273,7 @@ export class SimpleWorkerClient<T> extends Disposable {
}
private _request(method: string, args: any[]): TPromise<any> {
return new TPromise<any>((c, e, p) => {
return new TPromise<any>((c, e) => {
this._onModuleLoaded.then(() => {
this._protocol.sendMessage(method, args).then(c, e);
}, e);
......@@ -363,7 +363,7 @@ export class SimpleWorkerServer {
let cc: ValueCallback;
let ee: ErrorCallback;
let r = new TPromise<any>((c, e, p) => {
let r = new TPromise<any>((c, e) => {
cc = c;
ee = e;
});
......
......@@ -234,7 +234,7 @@ export abstract class AbstractProcess<TProgressData> {
if (this.cmd) {
childProcess = cp.spawn(this.cmd, this.args, this.options);
} else if (this.module) {
this.childProcessPromise = new TPromise<cp.ChildProcess>((c, e, p) => {
this.childProcessPromise = new TPromise<cp.ChildProcess>((c, e) => {
fork(this.module, this.args, <ForkOptions>this.options, (error: any, childProcess: cp.ChildProcess) => {
if (error) {
e(error);
......@@ -323,7 +323,7 @@ export abstract class AbstractProcess<TProgressData> {
}
private useExec(): TPromise<boolean> {
return new TPromise<boolean>((c, e, p) => {
return new TPromise<boolean>((c, e) => {
if (!this.shell || !Platform.isWindows) {
c(false);
}
......
......@@ -8,7 +8,7 @@
import * as errors from 'vs/base/common/errors';
import * as paths from 'vs/base/common/paths';
import URI from 'vs/base/common/uri';
import { PPromise, ProgressCallback, TProgressCallback, TPromise, TValueCallback } from 'vs/base/common/winjs.base';
import { PPromise, TProgressCallback, TPromise, TValueCallback } from 'vs/base/common/winjs.base';
export class DeferredTPromise<T> extends TPromise<T> {
......@@ -16,17 +16,15 @@ export class DeferredTPromise<T> extends TPromise<T> {
private completeCallback: TValueCallback<T>;
private errorCallback: (err: any) => void;
private progressCallback: ProgressCallback;
constructor() {
let captured: any;
super((c, e, p) => {
captured = { c, e, p };
super((c, e) => {
captured = { c, e };
}, () => this.oncancel());
this.canceled = false;
this.completeCallback = captured.c;
this.errorCallback = captured.e;
this.progressCallback = captured.p;
}
public complete(value: T) {
......@@ -37,10 +35,6 @@ export class DeferredTPromise<T> extends TPromise<T> {
this.errorCallback(err);
}
public progress(p: any) {
this.progressCallback(p);
}
private oncancel(): void {
this.canceled = true;
}
......
......@@ -11,7 +11,7 @@ suite('WinJS and ES6 Promises', function () {
test('Promise.resolve', function () {
let resolveTPromise;
const tPromise = new winjs.Promise(function (c, e, p) {
const tPromise = new winjs.Promise((c, e) => {
resolveTPromise = c;
});
......@@ -28,7 +28,7 @@ suite('WinJS and ES6 Promises', function () {
test('new Promise', function () {
let resolveTPromise;
const tPromise = new winjs.Promise(function (c, e, p) {
const tPromise = new winjs.Promise((c, e) => {
resolveTPromise = c;
});
......
......@@ -46,7 +46,7 @@ export function createTextBufferFactory(text: string): model.ITextBufferFactory
}
export function createTextBufferFactoryFromStream(stream: IStringStream, filter?: (chunk: string) => string): TPromise<model.ITextBufferFactory> {
return new TPromise<model.ITextBufferFactory>((c, e, p) => {
return new TPromise<model.ITextBufferFactory>((c, e) => {
let done = false;
let builder = createTextBufferBuilder();
......
......@@ -42,7 +42,7 @@ export class Colorizer {
let render = (str: string) => {
domNode.innerHTML = str;
};
return this.colorize(modeService, text, mimeType, options).then(render, (err) => console.error(err), render);
return this.colorize(modeService, text, mimeType, options).then(render, (err) => console.error(err));
}
private static _tokenizationSupportChangedPromise(language: string): TPromise<void> {
......@@ -54,7 +54,7 @@ export class Colorizer {
}
};
return new TPromise<void>((c, e, p) => {
return new TPromise<void>((c, e) => {
listener = TokenizationRegistry.onDidChange((e) => {
if (e.changedLanguages.indexOf(language) >= 0) {
stopListening();
......
......@@ -133,7 +133,7 @@ export class IntegrityServiceImpl implements IIntegrityService {
private _resolve(filename: string, expected: string): TPromise<ChecksumPair> {
let fileUri = URI.parse(require.toUrl(filename));
return new TPromise<ChecksumPair>((c, e, p) => {
return new TPromise<ChecksumPair>((c, e) => {
fs.readFile(fileUri.fsPath, (err, buff) => {
if (err) {
return e(err);
......
......@@ -208,7 +208,7 @@ class ExtensionManifestNLSReplacer extends ExtensionManifestHandler {
* Parses original message bundle, returns null if the original message bundle is null.
*/
private static resolveOriginalMessageBundle(originalMessageBundle: string, errors: json.ParseError[]) {
return new TPromise<{ [key: string]: string; }>((c, e, p) => {
return new TPromise<{ [key: string]: string; }>((c, e) => {
if (originalMessageBundle) {
pfs.readFile(originalMessageBundle).then(originalBundleContent => {
c(json.parse(originalBundleContent.toString(), errors));
......@@ -226,7 +226,7 @@ class ExtensionManifestNLSReplacer extends ExtensionManifestHandler {
* If the localized file is not present, returns null for the original and marks original as localized.
*/
private static findMessageBundles(nlsConfig: NlsConfiguration, basename: string): TPromise<{ localized: string, original: string }> {
return new TPromise<{ localized: string, original: string }>((c, e, p) => {
return new TPromise<{ localized: string, original: string }>((c, e) => {
function loop(basename: string, locale: string): void {
let toCheck = `${basename}.nls.${locale}.json`;
pfs.fileExists(toCheck).then(exists => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册