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