What is the best practice to have long living global effects? #1864
-
We are now migrating our application into using TCA and I'm quite new to the subject, so my question might be answered already, but I can't find where, so will be thankful for pointing in the right direction. What is the proper way of handling this in TCA? I have a feeling that it might be an architectural mistake on our end or if it should be handled differently with TCA, but I have no idea in which direction to look. So I will appreciate any advise, thank you! Have a great day! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @Paul-Svetlichny, I don't think you are using the library wrong or misunderstanding how things should be structured. While it is true that TCA's testing tools like you to exhaustively prove everything about the feature, including that all effects finish, sometimes that isn't possible. If you truly have an effect that lives for the entire duration of the app, then there is no user action that causes the effect to stop (other than force-quitting the app). So, you have two choices:
|
Beta Was this translation helpful? Give feedback.
Hi @Paul-Svetlichny, I don't think you are using the library wrong or misunderstanding how things should be structured. While it is true that TCA's testing tools like you to exhaustively prove everything about the feature, including that all effects finish, sometimes that isn't possible. If you truly have an effect that lives for the entire duration of the app, then there is no user action that causes the effect to stop (other than force-quitting the app).
So, you have two choices:
You can actually get a handle on the task that represents the lifetime of the effect in the test, and then cancel it once your test is complete: