Should stores call actions in reactjs flux? -
my current reactjs/flux implementation have components call actions, , actions call web api funnels store.
i have set of checkboxes state of checkboxes managed in store, every time update checkboxes, make query server state of store. forced call action update checkboxes store when checkboxes clicked, in checkboxes store, set variable "queryserver", in checkboxes component, check "queryserver" , make action query server.
it seems simpler if both components , stores can make action calls, way, when update checkboxes store, can initiate action query server directly without setting silly "queryserver" variable , having component check that.
though seem make things simpler, seems go agains essence of flux architecture actions initiated view.
my approach fetch state of store view , pass action there. allow store stay dumb possible, receiving data comes application.
in more specific terms, store have getdata function returns raw data stored. in component click handler checkboxes include code looking this:
var data = mystore.getdata(); myactions.queryserver(data); your action make api call (since it's safest place asynchronous) , pass new data store via dispatcher.
Comments
Post a Comment