本文整理汇总了TypeScript中rxjs/operators.isEmpty函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isEmpty函数的具体用法?TypeScript isEmpty怎么用?TypeScript isEmpty使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isEmpty函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: observableCombineLatest
const selectedViewsFromUrl: Observable<IView | null> = observableCombineLatest(routes, allViews.pipe(take(1)))
.pipe(
map(([route, views]) => {
if (!views || views.length == 0) return null;
const requestedView = route.relativePathSegments[1] || "";
if (!requestedView) return null;
const view = views.filter(v => v.name.toLowerCase() === requestedView.toLowerCase())[0];
return view ? view : null;
}),
filter(v => v != null)
);
// on first load, if no view is defined in the URL, check if there is only view and if so, select it
const automaticallySelectedSingleView: Observable<IView | null> = selectedViewsFromUrl
.pipe(
isEmpty(),
filter(isEmpty => isEmpty === true),
switchMap(() => allViews.pipe(
take(1),
filter(vs => vs != null && vs.length == 1),
map(vs => vs == null ? null : vs[0])
))
)
;
export const selectedViews: Observable<IView | null> = merge(
selectedViewsFromUrl,
automaticallySelectedSingleView
);
// fetching the data of a view
示例2: higherOrder
export function isEmpty<T>(this: Observable<T>): Observable<boolean> {
return higherOrder()(this);
}
示例3: it
it('should infer correctly', () => {
const o = of(1, 2, 3).pipe(isEmpty()); // $ExpectType Observable<boolean>
});
示例4: of
observable1 = constructorZone1.run(() => {
return of(1, 2, 3).pipe(isEmpty());
});