avdyushin / UDF_Swift

Uni-directional Data Flow in Swift
MIT License
1 stars 0 forks source link

Where to store State in Production code? #3

Open sirvon opened 6 years ago

sirvon commented 6 years ago

Thank You for sharing your findings.

In many ReSwift projects the author says, as you have...

Because it's demo project for simplify let's store the state as a static variable inside AppDelegate.swift:

Where to put the State object store in Production project?

avdyushin commented 6 years ago

It's good to use Dependency Injection in Production to make you code testable with unit tests. Once you have same struct Dependencies you can add one more property for application store. Then you can pass dependencies object to other objects which need to use store. Then in unit tests you can create mock store for your tests.