Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
mobile ruleP1universalStack: mobile
mobilelifecyclecancellationmemory
Cancel in-flight requests/tasks when the screen goes away
Requests tied to a screen must be cancelled on teardown so callbacks don't fire into a dead view or waste bandwidth.
PR: mobile-canon-2026-06Created: Jul 5, 2026
Bad example
Old codeswift
| 1 | // task keeps running after the view controller is dismissed |
Explanation (EN)
Objašnjenje (HR)
Good example
New codeswift
| 1 | deinit { task?.cancel() } // or rely on structured concurrency scope |
Explanation (EN)
Objašnjenje (HR)