How should we approach dependencies abstractions? #9
tgrapperon
started this conversation in
General
Replies: 1 comment 5 replies
-
Naming seems to be a common conflict in the Swift world 😭. One approach could be to create separate libraries for each dependency, then naming would be less significant. (maybe less overhead using imports, additionally it may be debatable about what dependencies to include in the main library, this could mitigate the significance of what dependencies are added) Although, this could seem excessive and less user-friendly. The prepended |
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
-
Hey everyone!
This is an open question. There are currently two ways to implement dependencies:
I currently adopted the first approach, where I'm exposing similar APIs to Apple's ones. This should allow users to seamlessly adopt these dependencies into their existing projects.
Given how
Dependencies
works, it is very easy to build powerful abstractions on top of these basic ones. This can be demonstrated by the currently experimental underscored dependencies like_AppStorage
or_Notification
.What's bothering me a little is that the keypath the basic dependencies are using is currently the one you would like to use by default for your abstractions.
So, as the library is very new, I'm contemplating namespacing "old-school" dependencies like:
(
system
, orstandard
, or whatever would make more sense here, I'm totally open for alternatives).Users willing to use this one as
@Dependency(\.notificationCenter)
would be able to define a computed property directly:Other ones would be able to use
notificationCenter
to build their own abstraction if they want.So in other words, I'm wondering if we should namespace these "ported" dependencies. We have a very small window of time to act, now that the library is very new, and I would like to know what you think about this.
Beta Was this translation helpful? Give feedback.
All reactions