当前位置: 首页>>代码示例>>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;未经允许,请勿转载。