Skip to content

paulz/CombineRetryDemo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

It looks like having tryCatch + retry will create a retain cycle. See issue

Steps to reproduce:

  • Launch App - CombineRetryDem
  • Tap - "Load HTML" button
  • Wait for prints in console. For example: completed finished
  • Tap "Back" button
  • Run Debug Memory Graph

image

Expected: HTMLViewController is deallocated and de inited is printed in console subscription is canceled and all the combine publishers are deallocated

Actual: HTMLViewController is deallocated and de inited is printed in console Retry and TryCatch are not deallocated and create retain cycle.

Context: For our use case we are using a sequence of Combine operators to make a request to a server. In the case where the request fails (server responds with expired token/invalid etc) we want to refresh our token inside the .tryCatch and retry the entire sequence from the beginning.

After experimenting we found that replacing retry by having all of our business logic inside the .tryCatch doesn't create a retain cycle but requires us to duplicate our sequence of operators. Is there a better approach we can use?

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%