Open yoshuawuyts opened 8 years ago
I'm currently looking for a way to put my choo app in a "busy" state with a loading indicator (spinner) while async processes are running. I think this might be the answer.
I'm currently looking for a way to put my choo app in a "busy" state with a loading indicator (spinner) while async processes are running. I think this might be the answer.
Uehhhh, this would be triggered for all actions - it doesn't feel like a great solution to your specific itch hey. Maybe applying reference counting wrappers around your xhr
calls and a subscription
that sets the state might be a better solution
edit: also these hooks can be considered globals - tying them to specific app logic def doesn't feel great (beyond calling send()
)
edit: yeah maybe this would work as a last resort solution; def def def not recommended - feels like overloading the application is not a great idea
OK. Thanks for the input. Maybe the subscription
is the way to go. :smile_cat:
@nickpeihl I'd recommend putting "isLoading" into your state and having your effects start by calling a reducer that sets it to true and then set it to false when the effect is done
@timwis This is a good idea. If I understand correctly, isLoading
could be placed in the app
namespace with the appropriate effects/reducers. But the async function I'm running is called from an effect in another model. My understanding is that it isn't appropriate for one model to call effects on another model. So maybe it's better to do this in a view with appropriate callbacks?
Called when an action is done; allows catching timers, and internally provide a stack trace for the
done()
callbacks - also allows to keep track of which actions are in transit and when they're completed :sparkles: