本文整理汇总了TypeScript中rxjs/operators.tap函数的典型用法代码示例。如果您正苦于以下问题:TypeScript tap函数的具体用法?TypeScript tap怎么用?TypeScript tap使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tap函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it(`supports font-awesome imports`, (done) => {
host.writeMultipleFiles({
'src/styles.scss': `
$fa-font-path: "~font-awesome/fonts";
@import "~font-awesome/scss/font-awesome";
`,
});
const overrides = { extractCss: true, styles: [`src/styles.scss`] };
runTargetSpec(host, browserTargetSpec, overrides).pipe(
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
).toPromise().then(done, done.fail);
}, 30000);
示例2: canActivate
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> {
return this.auth.user$.pipe(
take(1),
map(user => ((!user && this.auth.canEdit(user)))),
tap((canEdit: boolean) => {
if (!canEdit) {
console.error('Access denied. Must have permission to EDIT content');
}
})
);
}
示例3: intercept
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(request).pipe(
tap(
(event: HttpEvent<any>) => {},
(err: any) => {
if (err instanceof HttpErrorResponse) {
if (!(err.status === 401 && (err.message === '' || (err.url && err.url.includes('/api/account'))))) {
this.eventManager.broadcast({ name: 'bestMealApp.httpError', content: err });
}
}
}
)
);
}
示例4: filter
ngxsBootstrap<T>(action: T, results: StatesAndDefaults | undefined): void {
this.internalStateOperations
.getRootStateOperations()
.dispatch(action)
.pipe(
filter(() => !!results),
tap(() => this.invokeInit(results!.states)),
mergeMap(() => this.bootstrapper.appBootstrapped$),
filter(appBootstrapped => !!appBootstrapped)
)
.subscribe(() => {
this.invokeBootstrap(results!.states);
});
}
示例5: observe
observe(() => {
const {
job: { id }
} = createUpdateWithSchedule;
return updateJob(id, createUpdateWithSchedule).pipe(
tap(() =>
expect(mockRequest).toHaveBeenLastCalledWith(expect.anything(), {
body: JSON.stringify(createUpdateWithSchedule.schedule),
method: "PUT",
headers: expect.anything()
})
)
);
})
示例6: checkStore
checkStore(): Observable<boolean> {
return this.store.select(fromStore.getPizzasLoaded)
.pipe(
tap((loaded) => {
if (!loaded) {
this.store.dispatch(new fromStore.LoadPizzas());
}
}),
filter((loaded) => {
return loaded;
}),
take(1)
)
}
示例7: it
it('preserves script order', (done) => {
host.writeMultipleFiles(scripts);
const overrides = { scripts: getScriptsOption() };
runTargetSpec(host, browserTargetSpec, overrides).pipe(
tap((buildEvent) => expect(buildEvent.success).toBe(true)),
tap(() => {
const re = new RegExp(
/.*['"]input-script['"](.|\n|\r)*/.source
+ /['"]zinput-script['"](.|\n|\r)*/.source
+ /['"]finput-script['"](.|\n|\r)*/.source
+ /['"]uinput-script['"](.|\n|\r)*/.source
+ /['"]binput-script['"](.|\n|\r)*/.source
+ /['"]ainput-script['"](.|\n|\r)*/.source
+ /['"]cinput-script['"]/.source,
);
const fileName = './dist/scripts.js';
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
expect(content).toMatch(re);
}),
).toPromise().then(done, done.fail);
}, Timeout.Basic);
示例8: it
it('runs watch mode', (done) => {
const overrides = { watch: true };
runTargetSpec(host, { project: 'app', target: 'server' }, overrides).pipe(
tap((buildEvent) => {
expect(buildEvent.success).toBe(true);
const fileName = join(outputPath, 'main.js');
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
expect(content).toMatch(/AppServerModuleNgFactory/);
}),
take(1),
).subscribe(undefined, done.fail, done);
});
示例9: canActivate
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Observable<boolean> {
return this.store.select(s => s.environement).pipe(
map(env => env.uid),
map(uid => !!uid),
tap(hasUid => {
if (!hasUid) {
this.router.navigate(['/main/caption']);
}
})
);
}