-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Turn Flux Action Creators into Redux ones #390
Conversation
@@ -45,6 +45,10 @@ export const createReducerStore = ( reducer, initialState = {}, waitFor = [] ) = | |||
return ReducerStore; | |||
}; | |||
|
|||
function mergeStates( stores ) { |
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.
Are we using this somewhere?
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.
Oops, rebase remnant. Good catch, thx. Removed in 1860f7e
What’s the logic behind the new name |
They were indeed :-) It's mostly so the new Redux actions (which share a lot of their implementation with the old Flux actions) can remain in |
Continuing a previous discussion on helper methods for retrieving data from the stores.
Something I've been experimenting with in #338 is to introduce the concept of a "selector", intended to map the state tree to something more usable (as used here, fetching status or lists). The term selector is used by both
In #338, I created an entirely separate file for these types of functions, separate from both What are your thoughts on this? To be clear, this is not a request for changes to be made. I'm more interested in starting some dialogs around conventions we can try using with Redux. |
I think it's a great idea to follow established Redux patterns, especially if they make a whole lot of sense, as do selectors -- I just haven't seen and/or internalized all those patterns. That said, this PR has been lying around for a while (even though it ha actually less impact than yours -- it's still wrapping Redux for usage with Flux), so I'd rather not stack added complexity on top as to not further delay merging it. I'll open an issue though to move to the selector pattern later on. I'll also see to reviewing #338 soon. |
I trust this to be good, by now. It shouldn't disrupt anything. We've had enough eyeballs and whatever may come up after merging can be fixed. 👍 |
return this.fetch( site ); | ||
/** | ||
* On Jetpack sites, we're not querying themes using the REST API, but fetch all of the installed | ||
* themes (which typically aren't that many), and filter them within Calypso. |
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.
(which typically aren't that many)
We can probably lose the part of the comment in brackets without sacrificing any information.
1860f7e
to
5ed539c
Compare
Convert lib/themes/actions.js to Redux-style action creators (using `redux-thunk` for async actions, and `redux-analytics` middleware for actions involving analytics). Note that the `themes-last-event` reducer and store are removed, as the information they hold can be obtained from the `themes-list` reducer, while the analytics functionality is now implemented in lib/themes/middlewares. Props @mcsf
ee6592c
to
2bce856
Compare
…eators Turn Flux Action Creators into Redux ones
|
||
module.exports = ThemesActions; | ||
defer( () => { | ||
page( '/checkout/' + site.slug ); |
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.
Convert lib/themes/actions.js to Redux-style action creators
(using
redux-thunk
for async actions, andredux-analytics
middleware for actions involving analytics).
Note that the
themes-last-event
reducer and store are removed,as the information they hold can be obtained from the
themes-list
reducer, while the analytics functionality is now implemented in
lib/themes/middlewares.
Props @mcsf
CC @ehg @seear
To test:
calypso.localhost:3000/design
) still works as it should, including multi-site, single-site wpcom, and single-site Jetpack views.localStorage.setItem( 'debug', 'calypso:analytics' );
in the browser console, and reload) -- themes search and activation should trigger corresponding analytics events. Check that the correctsearch_term
is recorded. (Be aware of Search term not tracked when activating a theme from multisite #391, though --search_term
isn't properly recorded for activation or purchase from multisite.)