Why do we need isSending in Store implementation? #1698
Replies: 1 comment 1 reply
-
Hi @evilhonda3030, the A re-entrant action is when an action is sent while an action is currently being processed. We personally think people should try their hardest to avoid re-entrant actions, but we can't force that on people so we try our hardest to support it in the most reasonable way possible. To see a bunch of ways re-entrant actions can happen, just try commenting out this line in Store.swift and then run the test suite: You'll get a few failures, but more than that you will get test crashes. For example, the This clearly shows how a re-entrant action can happen. While processing Now, we don't think it's a good idea to ever do this, but some people have found themselves in this situation, and so we should support it. Another example is in this test: It sends an action from within the observation of a state change. This too causes an action to be sent while in the middle of processing an action. And all of this happens even though everything is single threaded and takes place on the main thread. So, we need to track |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi folks. First of all I want to thank all community around TCA and especially major TCA contributors for this wonderful spreading of all this info regarding to functional programming, redux and in general a new way to consider architecture of presentation layer.
Even I don't use TCA directly I was inspired by its approach so I am utilising likely a similar ad hoc solution.
First time, I was getting to know the codebase of TCA I was concerned by existence of isSending flag in send method of store. The reason it was put there is so unclear for me because TCA was invented as a single thread solution (queue) so all code executing on a single thread must follow each other sequentially. Basically I see here "code" as a single task or a single invocation of send method.
Taking into account this serial nature of TCA I can't understand how yet another callee of send method can invoke it before a previous invocation of send is finished
Why am I asking?
So basically to pose isSending was enough to solve exception but I am still confused because I can't understand why the overall situation is possible.
Could you guys elaborate on it? Thanks in advance!
P.S. I searched for another isSending question but it didn't answer mine unfortunately(
Beta Was this translation helpful? Give feedback.
All reactions