ElementaryEffectBuilder

main

Experimental, uni-directional and purely functional effect builder in Swift.
mkj-is/ElementaryEffectBuilder

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.

Description

  • Swift Tools 5.4.0
View More Packages from this Author

Dependencies

Last updated: Fri Mar 15 2024 01:42:19 GMT-0900 (Hawaii-Aleutian Daylight Time)