Replies: 1 comment 3 replies
-
I have rethought the whole issue and think the best solution is to move the access logic to the delegate and remove the One more thing, is the @Dependency(\.delegate.weakRef) var delegate
func reduce(into state: inout State, action: Action) -> EffectTask<Action> {
switch action {
case .tappedButton:
guard delegate?.canAccess(.unlimitedEntries) == true else { return .none }
state.isPresentedPicker = true
return .none
}
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First of all thank you for this excellent framework!
I couldn't find any information if nested DependencyKeys or delegates within DependencyKeys are an anti pattern to avoid. My use case is to have
canAccess
dependency key in a swift package framework. When a feature can't be accessed a delegate call is done to inform the app and show a screen.`canAccess` implementation details
The alternative would be to use two dependency keys and a bit of extra code, what means more code to maintain since
canAccess
anddelegate
pattern is used on some places in the codebase.What's your recommendation for such a use case?
Beta Was this translation helpful? Give feedback.
All reactions