本文整理汇总了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;
}
示例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);
}));
}
示例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;
});
}
示例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;
}
示例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'));
}
示例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);
}
示例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);
}
示例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');
});
示例9: it
it('flags service as actively geolocating', done => {
service.geolocate();
subscription.add(
service.geolocating$.subscribe(value => {
expect(value).toBe(true);
done();
})
);
});