View on GitHub

masmini-swift

Minimal Flux architecture written in Swift.

MasMini-Swift

The minimal expression of a Flux architecture in Swift.

Mini is built with be a first class citizen in Swift applications: macOS, iOS and tvOS applications. With Mini, you can create a thread-safe application with a predictable unidirectional data flow, focusing on what really matters: build awesome applications.

Release Version Release Date Pod Platform GitHub

Build Status codecov

Requirements

Installation

Carthage

Cocoapods

Usage

Architecture

State

struct MyCoolState: State {
    let cool: Bool?
    let coolTask: Task

    init(cool: Bool = nil,
         coolTask: Task = Task()
        ) {
        self.cool = cool
        self.coolTask = coolTask
    }

    // Conform to State protocol
    func isEqual(to other: State) -> Bool {
        guard let state = other as? MyCoolState else { return false }
        return self.cool == state.cool && self.coolTask == state.coolState
    }
}

Action

class RequestContactsAccess: Action {
  // As simple as this is.
}
extension Store where State == TestState, StoreController == TestStoreController {

    var reducerGroup: ReducerGroup {
        return ReducerGroup { [
            Reducer(of: OneTestAction.self, on: self.dispatcher) { action in
                self.state = self.state.copy(testTask: *.requestSuccess(), counter: *action.counter)
            }
        ] }
    }
}

If you are using SPM or Carthage, they doesn’t really allow to distribute assets with the library, in that regard we recommend to just install Sourcery in your project and use the templates that can be downloaded directly from the repository under the Templates directory.

var bag = DisposeBag()
let store = Store<TestState, TestStoreController>(TestState(), dispatcher: dispatcher, storeController: TestStoreController())
store
    .subscribe()
    .disposed(by: bag)

Dispatcher

let action = TestAction()
dispatcher.dispatch(action, mode: .sync)

Authors & Collaborators

License

Mini-Swift is available under the Apache 2.0. See the LICENSE file for more info.