Is it safe to call dispatch from multiple threads? #24
Description
Hello, thank you for introducing Redux to Android world.
I'm using bansa with Anvil and I think they are a very good match. But I noticed one thing, if we call BaseStore.dispatch()
from multiple thread, it's possible to get inconsistent state within one dispatch cycle, since we can't pass the new state to Anvil.render()
. We could only use BaseStore.getState()
in each view.
I noticed that you use locks in this line and getState(). But they both lock on different objects. synchronized(this)
locks on Middleware instance while public synchronized S getState()
locks on BaseStore instance.
But I think although we use locks, there is still a chance for inconsistent state since dispatch
and getState
will not be called in one block.
Do you think we should only call dispatch in one thread? Maybe using a single background thread to do it?
I'll be grateful to hear your thoughts about this. Thank you very much.