-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Description
Hi. I am trying to implement async flow with reducers.
And I am hot some kind of problem.
I have a remote resource (subtitles file), and URL to this resource can be changed with time (different languages etc.), also display of subtitles can be toggled.
I ended up with this shape of state:
{ url, isLoading, model, error, isActive, time }
And this list of an events:
URL_CHANGED, TIME_CHANGED, TOGGLED, LOADING_{START, FINISH, ERROR}
And this action creators:
toggle(), updateURL(url), updateTime(time)
Problem lies in business logic of url loading. URL should be loaded when user activate subtitles first time.
So in my toggle() and updateURL(url) action creators I have similar logic:
if (getState().isActive && !getState().isLoading) /* do loading */
This looks like business logic for me, and I cannot find a way to move it to reducer/store level.
Did I model task right? Or it require some separation?