ngrx effects error handling

前端 未结 3 745
迷失自我
迷失自我 2020-12-01 14:20

I have a very basic question concerning @ngrx effects: How to ignore an error that happens during the execution of an effect such that it doesn\'t affect future effect execu

3条回答
  •  执念已碎
    2020-12-01 14:43

    this is how I handle the option to be notified or not notified on Observables that didn't find any data:

     public listenCampaignValueChanged(emitOnEmpty: boolean = false): Observable {
            var campaignIdSelected$ = this.ngrxStore.select(store => store.appDb.uiState.campaign.campaignSelected)
            var campaigns$ = this.ngrxStore.select(store => store.msDatabase.sdk.table_campaigns);
            return campaignIdSelected$
                .combineLatest(campaigns$, (campaignId: number, campaigns: List) => {
                    return campaigns.find((i_campaign: CampaignsModelExt) => {
                        return i_campaign.getCampaignId() == campaignId;
                    });
                }).flatMap(v => (v ? Observable.of(v) : ( emitOnEmpty ? Observable.of(v) : Observable.empty())));
        }
    

提交回复
热议问题