Skip to content

1.15.0

Compare
Choose a tag to compare
@0xLeif 0xLeif released this 08 Mar 01:01
· 24 commits to main since this release
fbffe58

What's Changed

  • Added new Application.preview to be used in #Preview to override the needed dependencies for the content view. (Leif/preview improvements by @0xLeif in #98)
class Service {
    var title: String { "Live Service" }
}

class MockService: Service {
    override var title: String { "Mock Service" }
}

extension Application {
    var service: Dependency<Service> {
        dependency(Service())
    }
}

struct ContentView: View {
    @AppDependency(\.service) private var service

    var body: some View {
        Text(service.title)
    }
}

#Preview {
    Application.preview(
        Application.override(\.service, with: MockService()),
        Application.override(\.userDefaults, with: UserDefaults())
    ) {
        ContentView()
    }
}

Full Changelog: 1.14.0...1.15.0