Replies: 1 comment 2 replies
-
The decision is really up to you and your team, but @mbrandonw and I like to treat dependencies that read from the outside world different from dependencies that write to the outside world. Dependencies that read (like the current date, a UUID, a random number, even getting a value from the user defaults) we feel are fine to access from a synchronous context and aren't going to do anything surprising, and we think it's not worth forcing them into Dependencies that write (like saving a file or setting a value on user defaults) we like to quarantine to an async context even if the underlying operation is synchronous and fast. This prevents you from invoking the dependency from the middle of a reducer's state update and instead forces you to open up an effect to do your work. This means effects that do something are all handled in a consistent way. |
Beta Was this translation helpful? Give feedback.
-
Why is the UserDefaults live client's set methods async?
@tgrapperon 's
swift-dependency-additions
package ships a UserDefaults dependency which set method is not asyncBeta Was this translation helpful? Give feedback.
All reactions