Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flux calling actions with arguments managed in store

Say I have an action someAction(params) that takes params which is managed in a store paramsStore:

paramsStore.listen(function(params) { 
  someAction(params)
}) 

It seems that I can't just call this in my view because apparently this goes against the Flux way of doing things (actions shouldn't be called within store listeners).

The reason I have someAction inside the store listener, is because I want it to be called every time the paramsStore is modified. How can I achieved this without resorting to the 'unpattern' of calling actions within stores listener?

like image 395
Luca Matteis Avatar asked Dec 01 '15 21:12

Luca Matteis


1 Answers

The right "flux way" of doing it would be to call the someAction(params) wherever information is dispatched to paramsStore.

Understanding what someAction does will give more clarity. Does it really need to be an action? If you're just doing some manipulation in the store data, you could have it as a local method in the paramStore.

flux architecture

like image 101
bigOmega ツ Avatar answered Sep 17 '22 16:09

bigOmega ツ