O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Store

We will store state in our Store object:

import ReactiveSwift import ReactiveCocoa import Delta struct Store: StoreType {     var state: ObservableProperty<State>     init(state: State) {         self.state = ObservableProperty(state)     } } var store = Store(state: State()) 

Store conforms to the StoreType protocol declared in the Delta library. The StoreType protocol defines the storage of an observable state and dispatch methods to modify it.

Here, we create a MutableProperty as state and store it in Store object.

We need to define properties to access and modify our state properly, so we extend our Store object as follows:

import ReactiveCocoa import ReactiveSwift import Result // MARK: Properties extension Store {  var todos: MutableProperty<[Todo]> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required