當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript BehaviorSubject.subscribe方法代碼示例

本文整理匯總了TypeScript中rxjs/Rx.BehaviorSubject.subscribe方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript BehaviorSubject.subscribe方法的具體用法?TypeScript BehaviorSubject.subscribe怎麽用?TypeScript BehaviorSubject.subscribe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rxjs/Rx.BehaviorSubject的用法示例。


在下文中一共展示了BehaviorSubject.subscribe方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: constructor

    constructor(private _data:DataService, private _user:UserService, private _cd:ChangeDetectorRef) {
        this.isAuth = new BehaviorSubject(false);
        this.privateData = new BehaviorSubject('');

        this.isAuth.subscribe(val => this.authStatus = val);
        this.privateData.subscribe(val => this.message = val);
    }
開發者ID:colinjlacy,項目名稱:firebase-ionic-2-demo,代碼行數:7,代碼來源:auth.ts

示例2: ngAfterViewInit

  ngAfterViewInit(){


		const text_input_element
		      = document.getElementById("text_container").getElementsByTagName("input")[0];
		const rx_txt_sub = new Rx.BehaviorSubject(text_input_element.value);

		const size_input_element
		      = document.getElementById("size_container").getElementsByTagName("input")[0];
		const rx_size_sub = new Rx.BehaviorSubject(size_input_element.value);

		const color_input_element
		      = document.getElementById("color_container").getElementsByTagName("input")[0];
		const rx_color_sub = new Rx.BehaviorSubject(size_input_element.value);



		const text_textbind = document.getElementById("text_bind");

		rx_txt_sub.subscribe((val)=>{
			text_textbind.innerText = val;
		})
		rx_size_sub.subscribe((val)=>{
			text_textbind.style.fontSize = val + "px";
		})
		rx_color_sub.subscribe((val)=>{
			text_textbind.style.color = val;
		})

		const bind = function(eType, elem, subject){
			Rx.Observable.fromEvent(elem, eType).subscribe( (e : any)=>{
				console.log(e.target.value)
				subject.next(e.target.value);
			})
		}
		bind('keyup',text_input_element, rx_txt_sub);
		bind('change',size_input_element, rx_size_sub);
		bind('change',color_input_element, rx_color_sub);

  }
開發者ID:morninng,項目名稱:angular2fire_chat,代碼行數:40,代碼來源:databind.component.ts

示例3: it

 it('if not passed any rows, does nothing', (done) => {
     var selection = new BehaviorSubject<{[key: string]: string}>({});
     var doOnce = false;
     selection.subscribe(() => {
         if (!doOnce) {
             doOnce = true;
         } else {
             done.fail('Changed the selection');
         }
     });
     
     SelectionUpdateStrategies.SimpleIteration(selection, null, d => d.id);
     setTimeout(done);
 });
開發者ID:Azure,項目名稱:azure-iot-library,代碼行數:14,代碼來源:grid.source.spec.ts

示例4: subscribe

 public subscribe(callback:StoreSubscriberCallback) {
     this.subject.subscribe(callback)
 }
開發者ID:pawelkocot,項目名稱:frp,代碼行數:3,代碼來源:store.ts

示例5: subscribe

 subscribe(callback: (value: Message) => void) {
     return this.eventDispatcher.subscribe(callback);
 }
開發者ID:RandyBoy,項目名稱:new-router,代碼行數:3,代碼來源:eventService.ts

示例6: setTimeout

/**
 * Created by 720718 on 2016/9/30.
 */

import * as Rx from 'rxjs/Rx';

const subject = new Rx.BehaviorSubject(0); // 0 is the initial value

subject.subscribe({
    next: (v) => console.log('behaviorSubject observerA: ' + v)
});

subject.next(1);
subject.next(2);

subject.subscribe({
    next: (v) => console.log('behaviorSubject observerB: ' + v)
});

subject.next(3);

setTimeout(() => { // plain subject
    console.log('='.repeat(80));
    const subject = new Rx.Subject();

    subject.subscribe({
        next: (v) => console.log('subject observerA: ' + v)
    });

    subject.next(1);
    subject.next(2);
開發者ID:szlevinli,項目名稱:studyRXJS,代碼行數:31,代碼來源:behavior-subject.ts


注:本文中的rxjs/Rx.BehaviorSubject.subscribe方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。