How to check Observable array Length in rxjs

Viewed 409

1) The below code accept the either X and Y and call some service and push the values to obeservable
2) When we give invaild input ie X,Y it must be giving empty result and obeservable must be empty and i have to throw some alert for invaild input
3) so How can i check for that condition here ?

I have tried isEmpty funtion and its not working please help me on this ?

const gridDataLoadRequest = GridDataLoadRequest
    .withLatestFrom(filterParams)
    .map(_.last);

return gridDataLoadRequest
    .map(partitionedCodesToSearchParams)
    .flatMap((vals) => {
        let [ X, Y ] = vals;

        let A = _.isEmpty(X.codes)
            ? Observable.of([])
            : storePlanningService.searchCustomerChoices(X);

        let B = _.isEmpty(Y.codes)
            ? Observable.of([])
            : storePlanningService.searchCustomerChoices(Y);

        return Observable.zip(A, B).map(_.flatten);
    })
    .publishReplay(1)
    .refCount();
};
1 Answers
Related