本文整理匯總了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)
}