Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add reducer for errors #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thmsobrmlr
Copy link

When fetching things from the api, we'd like to display error states. This adds a reducer to make the errorObject available for a loader.

@mariusandra
Copy link
Member

Nice. I think this could work... The reason this wasn't done already (despite several false starts) is:

  • Some consider storing non-jsonable structures in Redux to be yuk. This will now start putting Error objects in there.
  • I was wondering if we should just store error.message or be somewhat clever and never made a final decision.
  • Some people might have their own *Error reducers, and this will break things for them.
    ---> so I did got paralysed with overanalysis and did nothing.

However, yes, let's get this in.

I think the first two points are rather moot at the end of the day, but the last bullet needs to somehow be addressed. It might be useful to introduce a plugin option to selectively add the error objects, and leave it turned off for the v3.x versions.

The other question is around typing the error object. This will require some changes to kea-typegen/src/visit/visitLoaders.ts.

An alternative way is to export two functions: loaders() and loadersWithErrors(), and only make the changes in the new one... 🤔 or then have a magic __saveError: true key... 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants