Hacker News new | ask | show | jobs
by ianterrellwt 3502 days ago
I've been working with and on a project that uses a similar architecture. At least, it's using a Redux-like dataflow borrowed from ReSwift; views are standard iOS.

The benefits I've seen so far:

- Swift's type safety means you can validate at the type level that your app state is correct. As in, you could have an enum with separate cases for your authenticated and unauthenticated states, instead of optional values to indicate what state you're in. This makes your state stronger, in that the types hold only valid states rather than some possible states being invalid (e.g. unauthenticated with non-nil user info).

- State transitions -- reducer methods, (state,action) -> state -- are purely functional which makes (IMHO) feature work straightforward, testing trivial, and debugging fairly easy.

- Your view controllers become super dumb. All they have to do is render the data and relay input events. This is a nice clean separation of concerns.

- If your navigation route is managed in state, you get deep linking "for free". This is especially helpful in one of our apps for handling global errors that could occur on any network request (update state, route to error).

- Every bit of code has an easily identifiable home.

- Communicating between view controllers is simple. Rather than "passing the baton" as state is accumulated (say a multistep form), state accumulates naturally in the store.

I'm working on combining ReSwift with app coordinators here: https://github.com/willowtreeapps/cordux

I've written about it a little bit here: http://willowtreeapps.com/blog/app-coordinators-and-redux-on...

All that said, I still consider this an experiment. We've written about 40-50k lines of Swift across two apps with 8 developers so far, and opinions are mixed between considering it excellent and considering it burdensome.