本文整理汇总了TypeScript中rxjs/Rx.Subject.subscribe方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Subject.subscribe方法的具体用法?TypeScript Subject.subscribe怎么用?TypeScript Subject.subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxjs/Rx.Subject
的用法示例。
在下文中一共展示了Subject.subscribe方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: subscribeTopContacts
subscribeTopContacts(sub:(value: Contact[]) => void,count:number){
var topSub = (contacts) => {
sub(contacts.sort((first,second) => second.rank - first.rank).slice(0,count));
};
this.contacts.subscribe(topSub);
this.getData();
}
示例2: setTimeout
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);
subject.subscribe({
next: (v) => console.log('subject observerB: ' + v)
});
subject.next(3);
}, 0);
示例3: constructor
constructor() {
this.eventStream = new Subject()
this.eventStream.subscribe(
(ev) => { },
(err) => { },
() => { }
)
this.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
}
示例4:
/**
* Created by levin on 9/30/16.
*/
import * as Rx from 'rxjs/Rx';
const subject = new Rx.Subject();
subject.subscribe(x => console.log('A--->', x));
subject.subscribe(x => console.log('B----->', x));
subject.subscribe(x => console.log('C-------->', x));
subject.next(1);
subject.next(2);
subject.next(3);
示例5: subscribe
subscribe(sub:(value: Contact[]) => void){
this.contacts.subscribe(sub);
this.getData();
//this.contacts.next(this.contactsData);
}
示例6:
/**
* Created by 720718 on 2016/11/8.
*/
import * as Rx from 'rxjs/Rx';
const subject = new Rx.Subject();
subject.next('A');
console.log('start');
subject.subscribe(d => console.log('data:', d));
subject.next('B');
console.log('end');
subject.next('C');
示例7: setTimeout
setTimeout(() => {
subject.subscribe((data) => console.log('4th subject', data));
}, 5000);
示例8: subscribe
public subscribe(func: (state: SocketState) => void): ISubscription {
return this.stateSubject.subscribe(func);
}
示例9: subscribe
subscribe(next, err?, complete?) {
return this.subject.subscribe(next, err, complete)
}