ARTICLE AD BOX
I'm generally holding a Task variable to use cancel for an efficiency in somewhere. (and also calling cancel before setting the Task to avoid making duplicate asynchronous job.)
class Test { private var task: Task<Void, Never>? func start() { task?.cancel() task = Task { // do something with Task.isCancelled } } }But I realized that this code could make data race since task is a mutable thing and start can be called in anywhere. I know that it's time to use Actor, but I'm curious that this is always the best solution or not. With this concept, a whole thing that has variables needs to be an actor(view model, helper class, etc.). It could be like actor explosions for me.
Am I overthinking?
What is your best practice about when or where to use an actor?
