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

example-app - is removeBookFailure reducer correct? #2417

Closed
AdditionAddict opened this issue Feb 27, 2020 · 1 comment · Fixed by #2429
Closed

example-app - is removeBookFailure reducer correct? #2417

AdditionAddict opened this issue Feb 27, 2020 · 1 comment · Fixed by #2429

Comments

@AdditionAddict
Copy link
Contributor

Basically this SO post https://stackoverflow.com/questions/60417722/ngrx-handle-api-failure

Should line below be removed given it has no effect / should removeBook optimistically remove the book?
Happy to create PR whichever way

on(
    CollectionApiActions.addBookSuccess,
    CollectionApiActions.removeBookFailure, <-------------------
    (state, { book }) => {
      if (state.ids.indexOf(book.id) > -1) {
        return state;
      }
      return {
        ...state,
        ids: [...state.ids, book.id],
      };
    }
  ),

Describe any alternatives/workarounds you're currently using

Other information:

If accepted, I would be willing to submit a PR for this feature

[ x ] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No

@timdeschryver
Copy link
Member

This does seem weird.

I expect it to revert the removal of a book if the API call failed.
What is missing from the example app is the removal of the book in the collection when the removeBook action is dispatched.

The same counts for the addBook and addBookFailure actions.

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

Successfully merging a pull request may close this issue.

2 participants