<aside> đź’ˇ Derived is inspired by redux/reselect.


Derived’s functions are:


Create a Derived object from the Store

Select a tree from the state

let derived: Derived<Int> = store.derived(.map(\\.count))
// we can write also this.
// However, we recommend do above way as possible
// because it enables cache.
let derived: Derived<Int> = store.derived(.map { $0.count })

Technically, above method callings are produced from below declaration.

extension StoreType {

  public func derived<NewState>(
    _ memoizeMap: MemoizeMap<Changes<State>, NewState>, 
    dropsOutput: ((Changes<NewState>) -> Bool)? = nil,
    queue: TargetQueue? = nil
  ) -> Derived<NewState>


MemoizeMap manages to transform value from the state and keep performance that way of drops transform operations if the input value no changes.

Compute a value from the state

Derived can create any type of value what we need. MemoizeMap