Replies: 1 comment 3 replies
-
Short answer: 1. No. 2. & 3. Yes. Long answer: So the Effects.timer is just a wrapper around Timer Publisher with a .cancel public static func timer<S>(
id: AnyHashable,
every interval: S.SchedulerTimeType.Stride,
tolerance: S.SchedulerTimeType.Stride? = nil,
on scheduler: S,
options: S.SchedulerOptions? = nil
) -> Effect where S: Scheduler, S.SchedulerTimeType == Output {
Publishers.Timer(every: interval, tolerance: tolerance, scheduler: scheduler, options: options)
.autoconnect()
.setFailureType(to: Failure.self)
.eraseToEffect()
.cancellable(id: id)
} And from looking at cancellation source code you'd notice that Hashable id is used as a key to a dictionary of arrays with effects cancellations, hence same id will add the effect to the same key and will cancel all at once once requested. There might be subtle differences with |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
My question is regarding running Effect.timers with the same id and which of the outcomes out of the below 3 do we expect and can this be changed (or do we have to write our own TCA extensions to manage other cases not handled).
Beta Was this translation helpful? Give feedback.
All reactions