Replies: 1 comment 5 replies
-
Hi @JanC, when I run your code in a preview it works as I expect: ![]() The preview says "Hello mocked result". If you are seeing different can you provide a project that reproduces the problem? |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
hey there,
I'm having troubles to inject a dependency for a SwiftUI preview. I created a dependency with
liveValue
andpreviewValue
and that works as expectedThen I'd like to preview a specific use case where I configure the
MyMockClient
dependency so I create my preview like this:However, the preview still uses the instance of my mock created in
static let previewValue: APIClient = MyMockClient(result: "preview default value")
.I put some logs in the initialiser of
MyMockClient
and when I run the preview, I see it's created 2x when I run the SwiftUI preview:The complete code to reproduce it:
I also tried with the alternative syntax but the result is the same
What did I miss?
thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions