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


TypeScript Subject.subscribe方法代碼示例

本文整理匯總了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();
 }
開發者ID:adrpieper,項目名稱:angular2,代碼行數:7,代碼來源:contact.service.ts

示例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);
開發者ID:szlevinli,項目名稱:studyRXJS,代碼行數:18,代碼來源:behavior-subject.ts

示例3: constructor

 constructor() {
     this.eventStream = new Subject()
     this.eventStream.subscribe(
         (ev) => { },
         (err) => { },
         () => { }
     )
     
     this.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
 }
開發者ID:aheinrich,項目名稱:ng2-web-storage,代碼行數:10,代碼來源:indexeddb.service.ts

示例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);

開發者ID:szlevinli,項目名稱:studyRXJS,代碼行數:15,代碼來源:subject.ts

示例5: subscribe

 subscribe(sub:(value: Contact[]) => void){
   this.contacts.subscribe(sub);
   this.getData();
   //this.contacts.next(this.contactsData);
 }
開發者ID:adrpieper,項目名稱:angular2,代碼行數:5,代碼來源:contact.service.ts

示例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');
開發者ID:szlevinli,項目名稱:studyRXJS,代碼行數:16,代碼來源:test.ts

示例7: setTimeout

setTimeout(() => {
    subject.subscribe((data) => console.log('4th subject', data));
}, 5000);
開發者ID:szlevinli,項目名稱:studyRXJS,代碼行數:3,代碼來源:feature.ts

示例8: subscribe

 public subscribe(func: (state: SocketState) => void): ISubscription {
   return this.stateSubject.subscribe(func);
 }
開發者ID:mbpolan,項目名稱:retro-realms,代碼行數:3,代碼來源:socket.service.ts

示例9: subscribe

 subscribe(next, err?, complete?) {
   return this.subject.subscribe(next, err, complete)
 }
開發者ID:visualkhh,項目名稱:spring_util,代碼行數:3,代碼來源:layout.service.ts


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