Introduce action creators

These can be used to dispatch actions immediately, or after some asynchronous
work has been done. Also, create GroupActions.fetchJoinedGroups as an example.

The concept of async action creators can be used in the following cases:
 - stores or views that do async work, dispatching based on the results
 - actions that have complicated payloads, would make more sense as functions
   with documentation that dispatch created actions.
This commit is contained in:
Luke Barnard 2017-12-07 14:17:32 +00:00
parent 65d88334a9
commit ee6df105fe
4 changed files with 64 additions and 16 deletions

View file

@ -52,10 +52,10 @@ class TagOrderStore extends Store {
this._setState({orderedTags});
}
break;
// Initialise the state such that if account data is unset, default to the existing ordering
case 'all_tags':
// Initialise the state such that if account data is unset, default to joined groups
case 'GroupActions.fetchJoinedGroups.success':
this._setState({
allTags: payload.tags.sort(), // Sort lexically
allTags: payload.result.groups.sort(), // Sort lexically
});
break;
// Puts payload.tag at payload.targetTag, placing the targetTag before or after the tag