本文整理匯總了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);
});