Open paulstatezny opened 9 years ago
There is still discussion to be had about AbstractStore.handleApiAction
and how it should relate to loaded
flags.
Is this going to handle the definition of constants at all? One concern I have is that it hides the existence of the "GET_FOO_SUCCESS" and "GET_FOO_FAILURE" constants and that could confuse someone when they just add "GET_FOO" to the constants file and nothing works.
Good question. We could make it more verbose:
this.performApiAction(fooClient.getFoo(fooId, fooFilters), 'GET_FOO', 'GET_FOO_SUCCESS', 'GET_FOO_FAILURE');
But I think part of the complaint is wanting to minimize the boilerplate.
Adding this here from our lunch discussion - I would rather go the direction of making the "SUCCESS" and "FAILURE" constants totally internal and only having the programmer specify a constant representing the name of the action. That way we're not requiring a programmer to explicitly define constants in order for our shorthand convention to work properly. I'm not sure what the implementation of this looks like yet without digging into fluxxor a little more.
Extract Common Patterns in Stores and Actions
Acceptance Criteria
AbstractActionCreator
class exists with aperformApiAction
method. The method abstracts away the most common use case in action creators: Performing an API call and dispatching flux actions on success/error with the response body as payload.action + '_SUCCESS'
on success, and+ '_FAILURE'
on failure, both with the responses received as the payloads.AbstractStore
class exists with ahandleApiAction
method, which is designed to simply receive a payload and store it to a given property and then emit a change event.Tasks
Additional Notes