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