本文整理匯總了TypeScript中rxjs/Subject.Subject.debounceTime方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Subject.debounceTime方法的具體用法?TypeScript Subject.debounceTime怎麽用?TypeScript Subject.debounceTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rxjs/Subject.Subject
的用法示例。
在下文中一共展示了Subject.debounceTime方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: action
export const subjectDebounce = <T>(subject: Subject<T>, dueTime: number, action : (T) => void): void => {
let sub = subject.debounceTime(dueTime).distinctUntilChanged().subscribe(p => action(p));
let sub1 = subject.subscribe(null, null, () => {
sub.unsubscribe();
sub1.unsubscribe();
})
}
示例2: ngOnInit
ngOnInit() {
this.draftUpdateSubscription = this.draftUpdate
.debounceTime(1000)
.subscribe(this.saveVerbDraft.bind(this));
this.routeDataSubscription = this.route.data.withLatestFrom(this.route.params).subscribe((values) => {
var wobEditState = values[0]["wobEditState"];
var verbName = values[1]["verb"];
this.onEditStateChange(wobEditState)
.then(() => {
// If specified verb exists, select it. Otherwise, use first
// verb in list.
if (verbName === undefined || !this.verbs[verbName]) {
verbName = this.firstVerb.name;
}
this.selectedVerb = this.verbs[verbName];
// Initialise editor if needed.
if (!this.editor) {
this.editor = ace.edit("editor");
this.editor.$blockScrolling = Infinity;
this.editor.setTheme("ace/theme/monokai");
this.editor.getSession().setMode("ace/mode/javascript");
this.editor.on("change", (event: Event) => {
if (!this.ignoreCodeChanges) {
this.onCodeChange(this.editor.getValue());
}
});
// Load editor configuration
this.aceConfig.setEditor(this.editor);
this.aceConfig.loadConfig();
}
// Avoid triggering draft creation when setting new code
// as a direct result of navigating to different verbs.
this.ignoreCodeChanges = true;
this.editor.setValue(this.selectedVerb.code, -1);
this.ignoreCodeChanges = false;
this.editor.scrollToLine(0);
});
});
this.routeParentParamsSubscription = this.route.parent.params.subscribe((params) => {
this.asAdmin = params["admin"] == "true" ? true : false;
});
}
示例3: updateComponentTree
const bind = (root) => {
const ngZone = root.injector.get(ng.coreTokens.NgZone);
if (ngZone) {
subscriptions.push(ngZone.onStable.subscribe(() => subject.next(void 0)));
}
// parse components and routes each time
subscriptions.push(
subject.debounceTime(0).subscribe(() => {
Promise.all([
updateComponentTree(getAllAngularRootElements().map(r => ng.probe(r))),
updateRouterTree()
]).then(() => onUpdateNotifier.next());
}));
// initial load
subject.next(void 0);
};
示例4: function
return function (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<Function>) {
console.log(target, propertyKey, descriptor);
let method = descriptor.value;
let targetDestroy = target.ngOnDestroy;
let subj = new Subject();
let debounced = subj.debounceTime(dueTime).distinctUntilChanged();
let sub = debounced.subscribe((val: any) => method.apply(val.that, val.args));
target.ngOnDestroy = function () {
sub.unsubscribe();
if (targetDestroy) {
targetDestroy();
}
}
descriptor.value = function() {
subj.next({that: this, args: arguments});
}
};
示例5: send
const bind = (root) => {
if (root.injector == null) {
// If injector is missing, we won't be able to debug this build
send(MessageFactory.applicationError(
new ApplicationError(ApplicationErrorType.DebugInformationMissing)));
return;
}
const ngZone = root.injector.get(ng.coreTokens.NgZone);
if (ngZone) {
subscriptions.push(ngZone.onStable.subscribe(() => subject.next(void 0)));
}
// parse components and routes each time
subscriptions.push(
subject.debounceTime(0).subscribe(() => {
updateComponentTree(getAllAngularRootElements().map(r => ng.probe(r)));
updateRouterTree(routerTree());
}));
// initial load
subject.next(void 0);
parseInitialModules(getAllAngularRootElements().map(r => ng.probe(r)));
};