-
I'm working on an app and using TCA. I have a need to have long running actions. For example, every 30 seconds I want to fetch a user object from my backend. I want this action to happen regardless of what view I'm on. When I get the user object I will check if it has a special key. If there is no special key then I will show a screen telling the user need to update their account accordingly. I was playing around with this timer. If I want these jobs / actions / tasks to run regardless of what view im on do I need to move the actions to my root / main feature? Note that I will be setting up NWConnections and these connections will be listening for incoming messages and when they get one they will need to do XYZ with them. Im trying to get an idea of how to have "background" things run in a TCA way. Thank you 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Bumping to get some eyes 👀 |
Beta Was this translation helpful? Give feedback.
Hi @captadoh, this doesn't really seem to be a TCA-specific question. You would approach this problem in vanilla SwiftUI in the exact same way. Your root feature will start up a long living effect which will run the timer and determine when something happens that causes the app to prompt the user.
Are you familiar with how effects are handled in TCA in general? If not, you may need to read more of the docs. But in short, you start effects from actions: