Skip to content

Experimental, uni-directional and purely functional effect builder in Swift.

License

Notifications You must be signed in to change notification settings

mkj-is/ElementaryEffectBuilder

Repository files navigation

ElementaryEffectBuilder

Elementary uni-directional architecture extension in Swift. This package function builder for creating and combining effects. It is inspired by Redux sagas.

Installation

When using Swift package manager install using Xcode 11+ or add following line to your dependencies:

.package(url: "https://github.com/mkj-is/ElementaryEffectBuilder.git", from: "0.1.0")

Usage

Main feature of this package is combining effects function into one:

let appEffect: Effect<AppState, AppAction> = buildEffect {
    createNetworkEffect()
    createPersistenceEffect()
    createUrlEffect()
}

Also take functions for building effects are provided. See the following example:

func createUrlEffect(application: UIApplication = .shared) -> Effect<AppState, AppAction> {
    take(
        AppAction.openHomepage,
        execute: { application.open(URL(string: "https://mkj.is")!) }
    )
}

Contributing

All contributions are welcome.

Project was created by Matěj Kašpar Jirásek.

Project is licensed under MIT license.