Effect cancellation via type name is being deprecated (.cancel(id: TimerID.self)
)
#2092
Replies: 4 comments 1 reply
-
+1 Safety first 👷 |
Beta Was this translation helpful? Give feedback.
-
I saw in a diff that this was what you all did, so I've already updated my codebase to reflect it :) it's a lot cleaner, that's for sure! |
Beta Was this translation helpful? Give feedback.
-
Is a case-ful enum your recommended way of doing this, as opposed to |
Beta Was this translation helpful? Give feedback.
-
Kind of an old discussion but I tend to use generated UUIDs in the state for this, just in case I have multiple instances of the Core up at the same time in the app. In most cases, this is impossible but it would be quite hard to debug if it ever occurred in the wild ^^ |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We wanted to announce an upcoming deprecation in TCA around effect cancellation coming in #2091. For a long time we have recommended and documented using static types as lightweight cancel IDs for effects. E.g.:
As much as we like this style, there is a bug in Swift that allows it to aggressively prune these symbols in release builds, which can even lead to breaking how cancellation works in your production TCA apps.
Because of this, we are deprecating support for this style, and will instead require simple hashable types, instead, which are not compiled out of release builds. Migration will require introducing a value to cancel with instead of relying on the type. E.g. you can add a
case
to the previously-empty enum:We hope it will be mostly painless, and that it will help you avoid introducing compiler-related bugs in your application.
Beta Was this translation helpful? Give feedback.
All reactions