-
Hello! I have watched with much interest as you have developed the Dependencies library, going back to the reducer protocol series. As ever, the from-first-principles teaching is so great. But a few times I would catch myself thinking: it seems like they're doing a lot of work to re-implement SwiftUI's I theorize the reason is: perhaps Is that the case, or is there some other fundamental benefit of Dependencies over |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @kamcma, It's a good question. The biggest reason why we can't leverage @Environment(\.colorScheme) var colorScheme;
print(colorScheme) You will get a purple runtime warning letting you know this isn't right:
But, even if that wasn't the case, there would be more reasons to not leverage But our dependencies library ships that tool, called Further, even if Apple shipped Hope that clears things up. |
Beta Was this translation helpful? Give feedback.
Hi @kamcma,
It's a good question. The biggest reason why we can't leverage
Environment
is, as you alluded to, it cannot be used outside a view. Just put this somewhere outside a view to see:You will get a purple runtime warning letting you know this isn't right:
But, even if that wasn't the case, there would be more reasons to not leverage
Environment
. All the tools Apple provides to update an environment value are baked directly into views. There is just the view modifier, e.g.en…