Skip to content

Execute an action onDisappear #2891

Closed Answered by mbrandonw
Alexminator99 asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, the effect being cancelled is all you need. If your effect is constructed using a Combine publisher then you can use something like .handleEvents or AnyCancellable to detect cancellation and clean up resources. Or if you are use Swift's async tools then you can use something like onTermination from AsyncStream.Continuation or withCancellationHandler.

Essentially it's your job to tap into cancellation in the effect and do the clean up. All the library needs to do is cancel the effect.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Alexminator99
Comment options

@mbrandonw
Comment options

Answer selected by Alexminator99
@Alexminator99
Comment options

@Alexminator99
Comment options

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