Threading & Object Lifetime
OnsideKit's main-actor threading model and the lifetime rules for request objects, observers, and delegates.
Threading: everything UI-facing is @MainActor
@MainActorObject lifetime: what you must retain
Request objects — retain until they finish
final class ProductLoader: OnsideProductsRequestDelegate {
private var request: OnsideProductsRequest? // strong reference
func load() {
let request = Onside.makeProductsRequest(productIdentifiers: ["my.product"])
request.delegate = self
self.request = request // retain for the whole request
request.start()
}
}Observers — retain and remove
Delegates — retain them too
Switching over OnsideKit enums
Checklist
Last updated
Was this helpful?