Harvest: A New Composable Architecture for SwiftUI

By Yasuhiro Inami

Elevator Pitch

What is the best iOS architecture for SwiftUI? MVVM? VIPER? Clean Architecture? Flux? Redux? Maybe it’s time to think about Elm Architecture! In this talk, we will explore Harvest as its successor, offering a functional reducer composition, unique effect-system, dependency injection, and so on.

Description

In WWDC 2019, Apple announced SwiftUI as a new generation UI framework for iOS development. While it brings us a new diff-rendering paradigm inspired by React, it doesn’t offer a good solution for simple data-flow and state-management that can easily get complex and spaghetti-ed across whole application. To simplify and decentralize each domain for more reusability and maintainability, we need more sophisticated solution: Composability. In this talk, we will explore Elm-like architecture called Harvest that offers unidirectional data-flow powered by Combine framework and functional reducer composition technique called Optics (Lens). We will also see the unique effect-system behind Harvest, and how mocks can be easily created through dependency injection for testing.