Another way to do that is to pass the context from the view to the ObservableObject whenever needed (with every function call). This will make you easily create unit tests for the view model (the observable object) by testing its functions using a mock context.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: