本文整理汇总了TypeScript中rxjs.Observable.empty方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Observable.empty方法的具体用法?TypeScript Observable.empty怎么用?TypeScript Observable.empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxjs.Observable
的用法示例。
在下文中一共展示了Observable.empty方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: type
type('should return T for ObservableLike objects', () => {
/* tslint:disable:no-unused-variable */
const o1: Observable<number> = from([] as number[], asapScheduler);
const o2: Observable<{ a: string }> = from(Observable.empty());
const o3: Observable<{ b: number }> = from(new Promise<{b: number}>(resolve => resolve()));
/* tslint:enable:no-unused-variable */
});
示例2: newgameReducer
.map(action => function newgameReducer(state) {
return {
past: state.past.concat(state.present),
present: O.empty(),
future: []
};
}),
示例3: showNotification
showNotification(channelId: ChannelId, from: string, text: string): void {
const settings = this._config.get();
if (settings.notification) {
// FIXME: should call in `NotificationActionCreator.showNotification()`
this._notifyAction.playSound();
}
if (settings.badge && Notification.permission === 'granted') {
let notification = new Notification(from + ' says:', {
body: text,
icon: ICON_URL,
});
const timeout: Rx.Observable<void> = Rx.Observable.empty<void>().delay(5 * 1000);
const click: Rx.Observable<void> = Rx.Observable.fromEvent<void>(notification, 'click').take(1).do<void>(() => {
this._uiAction.focusWindow();
this._uiAction.selectChannel(channelId);
});
const close: Rx.Observable<void> = click.race(timeout);
close.subscribe(function(){}, function(){}, function(){
notification.close();
notification = null;
});
}
}
示例4:
return observable.catch((err, source) => {
if (err.status == 401) {
//this._router.navigate(['/login']);
return Observable.empty();
} else {
return Observable.throw(err);
}
});
示例5:
return observable.catch((err, source) => {
if( err.status == 401 ) {
// Do something about error
return Observable.empty();
}
return Observable.throw(err);
});
示例6: child
.map(i => {
if (i % 2 === 1) {
return child(_sources, i);
} else {
return {
HTTP: Rx.Observable.empty(),
DOM: Rx.Observable.of(''),
};
}
})
示例7:
return observable.catch((err, source) => {
if ((err.status == 401 || err.status == 403) && !_.includes(err.url, 'app/auth/login') && !_.includes(err.url, 'app/auth/activate/by/key')) {
localStorage.removeItem('user_id');
localStorage.removeItem('name');
this.router.navigate(['']);
return Observable.empty();
} else {
return Observable.throw(err);
}
});
示例8:
return super.get(url, options).catch((err, caught) => {
if (err.status === 401
// && !_.endsWith(err.url, 'api/auth/login')
) {
// this._router.navigate(['/login']);
return Observable.empty();
} else {
return Observable.throw(err);
}
});
示例9: test
test('expect(stream-of-value).toBeStreamOf(value)', function() {
expect(Observable.empty()).toBeStreamOf(0);
expect(Observable.of(0)).toBeStreamOf(0);
expect(Observable.of(undefined)).toBeStreamOf(undefined);
expect(Observable.of('here')).toBeStreamOf('here');
expect(Observable.of(false)).toBeStreamOf(false);
expect(Observable.of(NaN)).not.toBeStreamOf(NaN);
expect(Observable.of(undefined)).not.toBeStreamOf(NaN);
expect(Observable.of('here')).not.toBeStreamOf(NaN);
expect(Observable.of(false)).not.toBeStreamOf(true);
});
示例10: test
test('NO ACTION, CR, but having only white space', function() {
const DOM = mockDOMSource(RxJSAdapter, {
'input.name': {
'keydown': O.of({
keyCode: 13,
target: {value: ' '}
})
}
});
expect(intent(DOM, O.empty()).isEmpty()).toBeStreamOf(true);
});