本文整理汇总了TypeScript中vs/base/common/async.RunOnceScheduler类的典型用法代码示例。如果您正苦于以下问题:TypeScript RunOnceScheduler类的具体用法?TypeScript RunOnceScheduler怎么用?TypeScript RunOnceScheduler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RunOnceScheduler类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: colorize
public static colorize(modeService:IModeService, text:string, mimeType:string, options:IColorizerOptions): TPromise<string> {
options = options || {};
if (typeof options.tabSize === 'undefined') {
options.tabSize = 4;
}
let lines = text.split('\n');
let c: (v:string)=>void;
let e: (err:any)=>void;
let p: (v:string)=>void;
let isCanceled = false;
let mode: IMode;
let result = new TPromise<string>((_c, _e, _p) => {
c = _c;
e = _e;
p = _p;
}, () => {
isCanceled = true;
});
let colorize = new RunOnceScheduler(() => {
if (isCanceled) {
return;
}
let r = actualColorize(lines, mode, options.tabSize);
if (r.retokenize.length > 0) {
// There are retokenization requests
r.retokenize.forEach((p) => p.then(scheduleColorize));
p(r.result);
} else {
// There are no (more) retokenization requests
c(r.result);
}
}, 0);
let scheduleColorize = () => colorize.schedule();
modeService.getOrCreateMode(mimeType).then((_mode) => {
if (!_mode) {
e('Mode not found: "' + mimeType + '".');
return;
}
if (!_mode.tokenizationSupport) {
// wait 500ms for mode to load, then give up
TPromise.any([this._tokenizationSupportChangedPromise(_mode), TPromise.timeout(500)]).then(_ => {
if (!_mode.tokenizationSupport) {
e('Mode found ("' + _mode.getId() + '"), but does not support tokenization.');
return;
}
mode = _mode;
scheduleColorize();
});
return;
}
mode = _mode;
scheduleColorize();
});
return result;
}
示例2: onCursorPositionChanged
private onCursorPositionChanged(): void {
if (this.triggerAutoSuggestPromise) {
this.triggerAutoSuggestPromise.cancel();
this.triggerAutoSuggestPromise = null;
}
this.cancelDialog();
if (!this.updateScheduler) {
this.updateScheduler = new RunOnceScheduler(() => {
const pos = this.editor.getPosition();
let marker = this.lastMarker;
if (marker && Range.containsPosition(marker, pos)) {
// still on the same marker
if (this.lightBulpPosition) {
this.setDecoration(pos);
}
return;
}
if (!this.editor.isFocused()) {
// remove lightbulb when editor lost focus
this.setDecoration(null);
return;
}
this.lastMarker = marker = this.findMarker(pos, false);
if (!marker) {
// remove lightbulp
this.setDecoration(null);
return;
}
const $tRequest = timer.start(timer.Topic.EDITOR, 'quickfix/lighbulp');
const computeFixesPromise = this.computeFixes(marker);
computeFixesPromise.done((fixes) => {
this.setDecoration(!arrays.isFalsyOrEmpty(fixes) ? pos : null);
this.triggerAutoSuggest(marker);
$tRequest.stop();
}, (error) => {
onUnexpectedError(error);
this.setDecoration(null);
$tRequest.stop();
});
}, 250);
this.toLocalDispose.push(this.updateScheduler);
}
this.updateScheduler.schedule();
}
示例3:
show(delay?: number): void {
this.showDelayedScheduler.cancel();
if (typeof delay === 'number') {
this.showDelayedScheduler.schedule(delay);
} else {
show(this.element);
}
}
示例4:
this._toDispose.push(this._editor.addListener2(editorCommon.EventType.ModelContentChanged, (e:editorCommon.IModelContentChangedEvent) => {
if (this._ignoreModelContentChanged) {
return;
}
if (e.changeType === editorCommon.EventType.ModelContentChangedFlush) {
// a model.setValue() was called
this._decorations.reset();
}
this._decorations.setStartPosition(this._editor.getPosition());
this._updateDecorationsScheduler.schedule();
}));
示例5: cancel
public cancel(): void {
this._loadingMessageScheduler.cancel();
if (this._state === ComputeHoverOperationState.FIRST_WAIT) {
this._firstWaitScheduler.cancel();
}
if (this._state === ComputeHoverOperationState.SECOND_WAIT) {
this._secondWaitScheduler.cancel();
if (this._asyncComputationPromise) {
this._asyncComputationPromise.cancel();
this._asyncComputationPromise = null;
}
}
if (this._state === ComputeHoverOperationState.WAITING_FOR_ASYNC_COMPUTATION) {
if (this._asyncComputationPromise) {
this._asyncComputationPromise.cancel();
this._asyncComputationPromise = null;
}
}
this._state = ComputeHoverOperationState.IDLE;
}
示例6: start
public start(mode: HoverStartMode): void {
if (mode === HoverStartMode.Delayed) {
if (this._state === ComputeHoverOperationState.IDLE) {
this._state = ComputeHoverOperationState.FIRST_WAIT;
this._firstWaitScheduler.schedule(this._firstWaitTime());
this._loadingMessageScheduler.schedule(this._loadingMessageTime());
}
} else {
switch (this._state) {
case ComputeHoverOperationState.IDLE:
this._triggerAsyncComputation();
this._secondWaitScheduler.cancel();
this._triggerSyncComputation();
break;
case ComputeHoverOperationState.SECOND_WAIT:
this._secondWaitScheduler.cancel();
this._triggerSyncComputation();
break;
}
}
}
示例7: _triggerAsyncComputation
private _triggerAsyncComputation(): void {
this._state = ComputeHoverOperationState.SECOND_WAIT;
this._secondWaitScheduler.schedule(this._secondWaitTime());
if (this._computer.computeAsync) {
this._asyncComputationPromiseDone = false;
this._asyncComputationPromise = createCancelablePromise(token => this._computer.computeAsync!(token));
this._asyncComputationPromise.then((asyncResult: Result) => {
this._asyncComputationPromiseDone = true;
this._withAsyncResult(asyncResult);
}, (e) => this._onError(e));
} else {
this._asyncComputationPromiseDone = true;
}
}
示例8:
var scheduleColorize = () => colorize.schedule();