0

I have a itemsObservable, filtersObservable, and a queryObservable and feed their values to a function that takes a list of items, filter conditions, and a search query, and returns a filtered list.

Right now my code looks something like:

itemsObservable
    .flatMap(items => {
        filtersObservable
            .flatMap(filters => {
                queryObservable
                    .map(query => filterItems(items, filters, query))
             })
     });

Is there a better code pattern for this that eschews the deep nesting?

1 Answer 1

1
queryObservable.withLatestFrom(
    filtersObservable,
    itemsObservable,
    (query, filters, items) => filterItems(items, filters, query)
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.