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