Skip to content

Dependencies with input parameter #311

Answered by Almaz5200
AgapovOne asked this question in Q&A
Discussion options

You must be logged in to vote

If different places in your app require different values of ScreenSource you actually can create a dependency of type not just ServiceX, but (ScreenSource) -> ServiceX

Then you can provide it in runtime like

@Dependency(\.serviceX) var serviceXProvider
let serviceX = serviceXProvider(screenSource)

Also, your use case looks a lot like onboarding in isowords, so I recommend checking it out. It is most similar to your third option

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by AgapovOne
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants