Conversation
| return { type: 'BOOK_CREATE_SUCCESS', created }; | ||
| } | ||
|
|
||
| export function create(values) { |
There was a problem hiding this comment.
You can use the library type-to-reducer who manages the 3 states of a promise as you but with less code.
There was a problem hiding this comment.
As this is generated code, we try to use as few libraries as possible (especially not one having only 5 contributors).
There was a problem hiding this comment.
I did not see that you used the API platform generator :(
| import fetch from '../../utils/fetch'; | ||
|
|
||
| export function error(error) { | ||
| return { type: 'BOOK_CREATE_ERROR', error }; |
There was a problem hiding this comment.
Create a constant export const BOOK_CREATE_ERROR = 'BOOK_CREATE_ERROR'; in this file and use this constant in the reducer.
Attention, if you use the type-to-reducer library then the constant will be export const BOOK_CREATE = 'BOOK_CREATE';
There was a problem hiding this comment.
Is it really interesting here? It adds boilerplate code for just 1 reuse.
There was a problem hiding this comment.
According to https://github.com/reduxjs/redux/blob/master/docs/recipes/ReducingBoilerplate.md, I think it's not necessary for this small code generator (we try to keep the generated code minimal, it's up to the developper to add things like the constants)
There was a problem hiding this comment.
I agree with what you say, but if the developer has to rewrite the generated code every time, what exactly is the generator for?
|
@dunglas rebase PR please ;) |
|
Rebased. I removed the theme because it makes it very difficult to regenerate the client. |
Add Mercure support in the demo (WIP).
See: api-platform/core#2282 and https://dunglas.fr/2018/10/http-2-speed-up-your-apps-and-dispatch-real-time-updates-symfony-and-api-platforms-features-announcement/