dimillian,
@dimillian@mastodon.social avatar

I have only one item on my wishlist for Swift/SwiftUI.

Please move the environment pattern from #SwiftUI to #Swift and let us access our environments from anywhere in Swift.

ristkof,
@ristkof@mastodon.social avatar

@dimillian oh noes. Dependency injection without declaration is not a pattern I look forward to seeing often. Swift is meant to be safe, and Environment is a source for runtime errors.

dimillian,
@dimillian@mastodon.social avatar

@ristkof it’s not IMO. It's a runtime error telling the developer did something wrong. It's very stable now. I would not do a SwiftUI app without it.

Arcticulate,
@Arcticulate@toot.community avatar

@dimillian What about PreferenceKey? If not, maybe I misunderstood the use case.

dimillian,
@dimillian@mastodon.social avatar

@Arcticulate still something only reachable at the view level.

dimillian,
@dimillian@mastodon.social avatar

@Arcticulate still something only reachable at the view level.

jasonhowlin,
@jasonhowlin@mastodon.social avatar

@dimillian it was interesting to see UITraitCollection adopted something like this.

dasdom,
@dasdom@chaos.social avatar

@dimillian Swift already has globals. No need for branched globals. ;)

dimillian,
@dimillian@mastodon.social avatar

@dasdom To me it's not the same. Global is global. Environments are scoped. You can inject them in a hierarchy and have multiple versions of them.

dasdom,
@dasdom@chaos.social avatar

@dimillian This is what I mean with "branched globals".

dimillian,
@dimillian@mastodon.social avatar

@dasdom So need for branched globals :p

mikesax,
@mikesax@mas.to avatar

@dimillian Sometimes I think of environment variables as glorified global variables. But yes! 💯

dimillian,
@dimillian@mastodon.social avatar

@mikesax Not exactly the same to me. Env are scoped to a hierarchy. Obviously we need to define what a hierarchy is outside of the view level.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • SwiftUI
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines