当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Subscription.add方法代码示例

本文整理汇总了TypeScript中rxjs.Subscription.add方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Subscription.add方法的具体用法?TypeScript Subscription.add怎么用?TypeScript Subscription.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rxjs.Subscription的用法示例。


在下文中一共展示了Subscription.add方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: _init

 private _init(): Rx.Subscription {
     const d = new Rx.Subscription();
     d.add(this._list.subscribe());
     d.add(this._addedNetwork.subscribe());
     d.add(this._removedNetwork.subscribe());
     return d;
 }
开发者ID:karen-irc,项目名称:karen,代码行数:7,代码来源:NetworkSetDomain.ts

示例2: constructor

    constructor(socket: SocketIoDriver, action: MessageActionCreator) {
        this._socket = socket;

        const disposer = new Rx.Subscription();
        this._disposer = disposer;

        const messageDispatcher = action.dispatcher();

        disposer.add(socket.error().subscribe(function (e: any) { // tslint:disable-line:no-any
            /*eslint-disable no-console*/
            console.log(e);
            /*eslint-enable*/
        }));

        disposer.add(messageDispatcher.sendCommand.subscribe(({ channelId, text }) => {
            this._sendCommand(channelId, text);
        }));

        disposer.add(messageDispatcher.queryWhoIs.subscribe(({ channelId, user }) => {
            this._queryWhoIs(channelId, user);
        }));

        disposer.add(messageDispatcher.fetchHiddenLog.subscribe(({ channelId, length, }) => {
            this._fetchHiddenLog(channelId, length);
        }));
    }
开发者ID:saneyuki,项目名称:karen,代码行数:26,代码来源:MessageGateway.ts

示例3: constructor

    constructor(domain: DomainState, msgAction: MessageActionCreator, uiAction: UIActionCreator) {
        this._updater = new Rx.Subject<void>();

        const disposer = new Rx.Subscription();
        this._disposer = disposer;

        this._currentId = new None<ChannelId>();
        this._networkSet = new Set<Network>();
        this._notableChannelSet = new Set<ChannelId>();
        this._unreadCount = new Map<ChannelId, number>();

        const networkDomain = domain.getNetworkDomain();
        disposer.add(networkDomain.addedNetwork().subscribe((network: NetworkDomain) => {
            const value = network.getValue();
            this._addNetwork(value);
        }));

        disposer.add(networkDomain.removedNetwork().subscribe((network: NetworkDomain) => {
            const value = network.getValue();
            this._removedNetwork(value);
        }));

        disposer.add(networkDomain.joinedChannelAtAll().subscribe((channel) => {
            this._unreadCount.set(channel.getId(), channel.getValue().unread());
            this._updater.next(undefined);
        }));

        disposer.add(networkDomain.partedChannelAtAll().subscribe((channel) => {
            this._unreadCount.delete(channel.getId());
            this._updater.next(undefined);
        }));

        disposer.add(networkDomain.recievedNotableMessage().subscribe((message: RecievedMessage) => {
            this._highlightChannel(message);
        }));

        const currentId: Rx.Observable<Option<ChannelId>> =
            domain.getCurrentTab().map((v) => v.channelId).do((channelId: Option<ChannelId>) => {
                this._currentId = channelId;
                if (channelId.isSome) {
                    const id = channelId.unwrap();
                    this._notableChannelSet.delete(id);
                    this._unreadCount.set(id, 0);
                }
            });

        this._state = currentId.combineLatest<Option<ChannelId>, SidebarViewState>(this._updater, (selectedId) => {
            const array = Array.from(this._networkSet);
            const state = new SidebarViewState(array,
                                               selectedId,
                                               this._notableChannelSet,
                                               this._unreadCount,
                                               msgAction,
                                               uiAction);
            return state;
        });
    }
开发者ID:karen-irc,项目名称:karen,代码行数:57,代码来源:SidebarStore.ts

示例4: _init

 private _init(): Rx.Subscription {
     const d = new Rx.Subscription();
     d.add(this._topic.subscribe());
     d.add(this._userList.subscribe());
     d.add(this._notableMessage.subscribe((message) => {
         this._notableDispatcher.next(message);
     }));
     d.add(this._notifiableMessage.subscribe((message) => {
         this._notifiableMsgDispatcher.next(message);
     }));
     return d;
 }
开发者ID:karen-irc,项目名称:karen,代码行数:12,代码来源:ChannelDomain.ts

示例5: constructor

    constructor(element: Element, uiAction: UIActionCreator) {
        this._element = element;
        this._vm = new AppViewModel();

        const disposer = new Rx.Subscription();
        this._disposer = disposer;
        this._uiAction = uiAction;

        disposer.add(this._toggleLeftPane());
        disposer.add(this._toggleRightPane());
        disposer.add(this._handleClickEvent());

        this._vm.isOpenedLeftPane.setValue(element.classList.contains('lt'));
        this._vm.isOpenedRightPane.setValue(element.classList.contains('rt'));
    }
开发者ID:karen-irc,项目名称:karen,代码行数:15,代码来源:AppView.ts

示例6: openConfigureDialog

  openConfigureDialog() {
    const dialogSub = this.dialog.open(ConfigureComponent, {
      width: `1024px`,
      data: {
        chart$: this.chartDetails$,
      }
    }).afterClosed()
      .pipe(
        filter(values => values !== undefined),
        map(
          values => this.chartDetails$.pipe(
            map(chart => {
              chart.values = values;
              return chart;
            })
          )
        ),
        switchMap(values => values),
        tap((updatedValues) => {
          this.store.dispatch(new SetAppDetails(updatedValues));
        })
      ).subscribe(val => {
        console.log('res1', val);
      });

    this.subscriptons.add(dialogSub);
  }
开发者ID:supergiant,项目名称:supergiant,代码行数:27,代码来源:app-details.component.ts

示例7: setupLogging

  private async setupLogging() {
    // Stream that maps config updates to logger updates, including update failures.
    const update$ = this.configService.getConfig$().pipe(
      // always read the logging config when the underlying config object is re-read
      switchMap(() => this.configService.atPath('logging', LoggingConfig)),
      map(config => this.loggingService.upgrade(config)),
      // This specifically console.logs because we were not able to configure the logger.
      // eslint-disable-next-line no-console
      tap({ error: err => console.error('Configuring logger failed:', err) }),
      publishReplay(1)
    ) as ConnectableObservable<void>;

    // Subscription and wait for the first update to complete and throw if it fails.
    const connectSubscription = update$.connect();
    await update$.pipe(first()).toPromise();

    // Send subsequent update failures to this.shutdown(), stopped via loggingConfigSubscription.
    this.loggingConfigSubscription = update$.subscribe({
      error: err => this.shutdown(err),
    });

    // Add subscription we got from `connect` so that we can dispose both of them
    // at once. We can't inverse this and add consequent updates subscription to
    // the one we got from `connect` because in the error case the latter will be
    // automatically disposed before the error is forwarded to the former one so
    // the shutdown logic won't be called.
    this.loggingConfigSubscription.add(connectSubscription);
  }
开发者ID:horacimacias,项目名称:kibana,代码行数:28,代码来源:index.ts

示例8: it

  it('should convert observable obeject to ordinal object', done => {
    const aValue = new Subject();
    const bValue = new Subject();
    const BUFFER_COUNT = 4;

    const values = createObject(
      aValue.pipe(startWith('')),
      bValue.pipe(startWith('')),
    );

    subscription.add(
      combineTemplate(values)
        .pipe(bufferCount(BUFFER_COUNT))
        .subscribe(v => {
          /*tslint:disable:no-magic-numbers*/
          expect(v[0]).to.be.deep.eq(createObject('', ''));
          expect(v[1]).to.be.deep.eq(createObject('200', ''));
          expect(v[2]).to.be.deep.eq(createObject('200', '300'));
          expect(v[3]).to.be.deep.eq(createObject('OK', '300'));
          /*tslint:enable:no-magic-numbers*/
          done();
        }),
    );

    aValue.next('200');
    bValue.next('300');
    aValue.next('OK');
  });
开发者ID:brn,项目名称:react-mvi,代码行数:28,代码来源:combine-template.spec.ts

示例9: it

 it('flags service as actively geolocating', done => {
   service.geolocate();
   subscription.add(
     service.geolocating$.subscribe(value => {
       expect(value).toBe(true);
       done();
     })
   );
 });
开发者ID:ehunter-usgs,项目名称:earthquake-eventpages,代码行数:9,代码来源:geo.service.spec.ts


注:本文中的rxjs.Subscription.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。