-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[1.0] Use Redux for managing Gatsby's internal server state #777
Comments
Would the GraphQL plugins populate the store and the components receive data via react-redux or would GraphQL data continue to be part of each component? |
@jthiesse redux is only being used on the server piece not in the browser. It'll be invisible to users unless you're working on core code or some types of plugins. |
Check redux-query lib — it's so awesome. |
PR is up! Would love some reviews from people more familiar with Redux #788 |
Why don't you want to include redux as part of the generated app? There are situations where it makes a lot of sense |
@danielo515 you're free to add Redux if it's needed for your site... why would we want to always include it? |
Dear @KyleAMathews, I'm not talking about including it always. I'm talking about providing an easy way to include it ( like activation) . For example , Nuxt does not include Vuex by default, but if you create an index.js file at the store directory then Vuex is included automatically, and injected to the components . |
Ah gotcha! Yeah, that would be cool. This would be perfect for a Gatsby v1 plugin https://www.gatsbyjs.org/docs/plugins/ |
Nice to hear that ! Are you going to open an specific issue for that ? I would like to subscribe to it |
It's not something I'm going to work on anytime soon but this would be an
excellent community plugin to get going! If you want to take it on, open an
issue and I can point out the APIs you need and help with any roadblocks
you hit.
…On Tue, Apr 11, 2017, 11:34 AM Daniel Rodríguez Rivero < ***@***.***> wrote:
Nice to hear that ! Are you going to open an specific issue for that ? I
would like to subscribe to it
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#777 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEVhxNij7ukFhr4wZ4iJzsfdKWbCOcAks5ru8fBgaJpZM4MyW-D>
.
|
…fixes #777 (#788) * Use DataTree instead of Abstract Syntax Tree The idea for how to do things was taken from compilers but since we're not actually parsing syntax into a tree, using AST terminology is confusing. DataTree seems like a more sensible name. * Add a watch command for all packages and update contributing instructions * Add trailing slash when creating script tags for prefixed sites * Add redux, convert all globals except pages to use it * Add more tests + convert node api signature to (args, pluginOptions) to make same as browser/ssr api signature * Use Redux for managing data nodes + initial rough implemenation of hot reloading * Move raw action dispatching to action creator * Add nodes tests * Update windows docs * Update CONTRIBUTING.md * Somewhat reliable draining * Upgrade gatsbygram for PR * Up sites to latest canary
This is now merged |
…fixes gatsbyjs#777 (gatsbyjs#788) * Use DataTree instead of Abstract Syntax Tree The idea for how to do things was taken from compilers but since we're not actually parsing syntax into a tree, using AST terminology is confusing. DataTree seems like a more sensible name. * Add a watch command for all packages and update contributing instructions * Add trailing slash when creating script tags for prefixed sites * Add redux, convert all globals except pages to use it * Add more tests + convert node api signature to (args, pluginOptions) to make same as browser/ssr api signature * Use Redux for managing data nodes + initial rough implemenation of hot reloading * Move raw action dispatching to action creator * Add nodes tests * Update windows docs * Update CONTRIBUTING.md * Somewhat reliable draining * Upgrade gatsbygram for PR * Up sites to latest canary
I've been prototyping using Redux for managing Gatsby's internal server/cli state to replace the somewhat ad-hoc data management code.
I needed to refactor this code anyways to get data hot reloading working (#1 requested feature for people experimenting with Gatsby v1) and figured I'd try this out.
I'm about 1/2 way through ripping out the old code and replacing it with Redux but I've very positive about the direction. The data flows are much simpler, much more testable, and it's suggesting very positive changes to a few Gatsby APIs.
And the nice thing about Redux is since the community is huge, like with GraphQL, we'll get freebies by adopting Redux.
E.g. built-in devtools support.
This screenshot is the Redux devtools looking at an action from my Gatsby blog where I opened a markdown file, made a small change, and saved it and this is the resulting state diff.
In addition to the nice code improvements plus our now built-in supercharged debugger, using Redux will make Gatsby's code base feel very approachable to many of its users who will have experience using Redux on client-side apps.
The text was updated successfully, but these errors were encountered: