error
функции subscribe
- это означает что поезд ушел и прийдётся что-то мудрить чтоб переподписаться на fromEvent<any>(this.sendBtn.nativeElement, 'click')
import { EMPTY } from 'rxjs';
fromEvent<any>(this.sendBtn.nativeElement, 'click')
.pipe(
map((event) => event.target.value),
tap(() => this.documentSend$.next(true)),
switchMap(() =>
this.applicationDocumentsService
.sendrequest({
appid: this.appid,
req: this.requestDocument,
})
.pipe(
cachError((error: HttpErrorResponse) => {
this.messageService.showMessage('', `${err.error}`, 'error');
return EMPTY;
}),
finalize(() => this.documentSend$.next(false)),
)
),
takeUntil(this.closed$)
)
.subscribe((response) => {
console.log(response);
this.dialogRef.close(response);
});
game$.subscribe((action) => {
switch (action[0]) {
case 'ArrowUp':
if(state.y > 0) { state.y--; }
break;
case 'ArrowRight':
if(state.x < gameWidth - 1) { state.x++; }
break;
case 'ArrowDown':
if(state.y < gameHeight - 1) { state.y++; }
break;
case 'ArrowLeft':
if(state.x > 0) { state.x--; }
break;
}
state.walls = action[1];
renderGame(state);
console.log(state)
});
// Да, сначала мы делаем map, потому что он делается полюбому:
let doSomething$ = this.myApi.getSomething(id).pipe(
map(tags => ({ ...updatedShop, tags }))
)
// А затем мы делаем mergeMap если понадобится:
if (shop.isNew) {
doSomething$ = doSomething$.pipe(
mergeMap(() =>
this.myApi.addTags(updatedShop.id, shop.tags).pipe(
map(() => {
return {
...updatedShop,
tags: shop.tags
};
})
)
)
)
}
// ну и затем подписываемся на это дело чтоб оно начало работать:
doSomething$.subscribe();
this.myApi.getSomething(id).pipe(
map(tags => ({ ...updatedShop, tags })),
mergeMap((tags) => {
if (!shop.isNew) {
return of(tags);
}
return this.myApi.addTags(updatedShop.id, shop.tags).pipe(
map(() => {
return {
...updatedShop,
tags: shop.tags
};
})
)
}),
)