Skip to content

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

Merged
merged 15 commits into from
Jan 13, 2019
Merged

Mercure demo #66

merged 15 commits into from
Jan 13, 2019

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Oct 26, 2018

return { type: 'BOOK_CREATE_SUCCESS', created };
}

export function create(values) {
Copy link
Contributor

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.

Copy link
Member Author

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).

Copy link
Contributor

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 };
Copy link
Contributor

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';

Copy link
Member Author

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.

Copy link
Member Author

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)

Copy link
Contributor

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?

@toofff
Copy link
Contributor

toofff commented Jan 3, 2019

@dunglas rebase PR please ;)

@dunglas
Copy link
Member Author

dunglas commented Jan 11, 2019

Rebased. I removed the theme because it makes it very difficult to regenerate the client.

@dunglas dunglas merged commit 469e36c into api-platform:master Jan 13, 2019
@dunglas dunglas deleted the mercure branch January 13, 2019 19:52
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