-
-
Notifications
You must be signed in to change notification settings - Fork 224
Mercure demo #66
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
Mercure demo #66
Conversation
return { type: 'BOOK_CREATE_SUCCESS', created }; | ||
} | ||
|
||
export function create(values) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really interesting here? It adds boilerplate code for just 1 reuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/