Skip to content

Long running actions #3702

Answered by mbrandonw
captadoh asked this question in Q&A
Jun 8, 2025 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

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:

case .onAppear:
  return .run { send in 
    // Do whatever async work you want in here
  }

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mbrandonw
Comment options

Answer selected by captadoh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants