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