当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Subject.debounceTime方法代码示例

本文整理汇总了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();
    })
}
开发者ID:baio,项目名称:link-shortener,代码行数:8,代码来源:subject-debounce.ts

示例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;
		});
	}
开发者ID:deciare,项目名称:flowerbox-web-angular,代码行数:47,代码来源:verb-editor.component.ts

示例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);
};
开发者ID:Jigar3758,项目名称:augury,代码行数:18,代码来源:backend.ts

示例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});
        }
    };
开发者ID:baio,项目名称:link-shortener,代码行数:23,代码来源:debounce-decorator.ts

示例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)));
};
开发者ID:JayKan,项目名称:augury,代码行数:24,代码来源:backend.ts


注:本文中的rxjs/Subject.Subject.debounceTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。