本文整理汇总了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);
}
示例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);
}
示例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);
});
示例4: subscribe
public subscribe(callback:StoreSubscriberCallback) {
this.subject.subscribe(callback)
}
示例5: subscribe
subscribe(callback: (value: Message) => void) {
return this.eventDispatcher.subscribe(callback);
}
示例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);