當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。