Skip to content

Question: Why can't we support createAsyncSelector? #691

Open
@xotahal

Description

@xotahal

Hey folks! 👋 First of all, great work on this library! 👏

I have a question. I'd like to understand where the problem lies. I know that reselect doesn't support async selectors, and if we need to fetch data, we should use a thunk or another approach. That's fine and it works. But what if we need to use, let's say, a 3rd party library inside of a selector that computes something, but does that only in an async way?

For example, something like this:

const asyncSelector = createAsyncSelector(
   (state) => state.a,
   (state) => state.b,
   async (a, b) => {
     return await computeSomethingAsync(a, b);
   }

Also, if I want to use this as the input of another async selector:

const anotherAsyncSelector = createAsyncSelector(
   asyncSelector,
   (state) => state.c,
   async (resultAB, c) => {
     return await computeSomethingAsync(resultAB, c);
   }

I would just like to understand why this is considered an antipattern. Why can't we support this? This is not a case of fetching data; it's deriving data from the Redux store asynchronously.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions