rxjs#first TypeScript Examples
The following examples show how to use
rxjs#first.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: options-addon-section.component.ts From WowUp with GNU General Public License v3.0 | 6 votes |
private onWagoEnable(option: MatListOption) {
const providerName: AddonProviderType = option.value;
const title: string = this._translateService.instant("DIALOGS.PERMISSIONS.WAGO.TOGGLE_LABEL");
const message: string = this._translateService.instant("DIALOGS.PERMISSIONS.WAGO.DESCRIPTION", {
termsUrl: AppConfig.wago.termsUrl,
dataUrl: AppConfig.wago.dataConsentUrl,
});
const dialogRef = this._dialogFactory.getConfirmDialog(title, message);
dialogRef
.afterClosed()
.pipe(
first(),
switchMap((result) => {
if (result) {
return from(this._addonProviderService.setProviderEnabled(providerName, option.selected));
} else {
option.selected = !option.selected;
}
return of(undefined);
}),
catchError((err) => {
console.error(err);
return of(undefined);
})
)
.subscribe();
}
Example #2
Source File: wowup-protocol.service.ts From WowUp with GNU General Public License v3.0 | 6 votes |
public onInstallProtocol(protocol: string) {
console.log("onInstallProtocol", protocol);
const dialog = this._dialogFactory.getDialog(InstallFromProtocolDialogComponent, {
disableClose: true,
data: {
protocol,
},
});
return dialog.afterClosed().pipe(first());
}
Example #3
Source File: search.spec.ts From platyplus with MIT License | 6 votes |
describe('monitor changes', () => {
const expression$ = 'a.b.c'
const given = from([
{ a: { b: { c: 'hello' } } },
{ a: { b: { c: 'world' } } }
])
it('should pass when changing value', (done) => {
given
.pipe(search$(expression$))
.pipe(first())
.subscribe({
next: (result) => {
expect(result).toEqual('hello')
},
error: done
})
given
.pipe(search$(expression$))
.pipe(last())
.subscribe({
next: (result) => {
expect(result).toEqual('world')
done()
},
error: done
})
}, 300)
})