bwoods / Architecture

Heavily inspired by Point•Free’s Swift Composable Architecture (aka The Composable Architecture)

Home Page:https://bwoods.github.io/Architecture/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A Composable Architecture

The Swift Composable Architecture library improves upon previous Redux-inspired patterns by leveraging the capabilities of the Swift language to achieve better Type Safety, Ergonomics and Performance.

This crate attempts to do the same to the Swift Composable Architecture itself by further leveraging the capabilities of the Rust language and ecosystem.

What is the Swift Composable Architecture?

The Composable Architecture (TCA, for short) is a library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind. It can be used in SwiftUI, UIKit, and more, and on any Apple platform (iOS, macOS, tvOS, and watchOS).

Learn More

The Composable Architecture was designed over the course of many episodes on Point•Free, a video series exploring functional programming and the Swift language, hosted by Brandon Williams and Stephen Celis.

You can watch all of the episodes here, as well as a dedicated, multipart tour of the architecture from scratch: part 1, part 2, part 3 and part 4.

The API has diverged to better reflect the different strengths (and weaknesses) of Rust and Swift, but the core ideals are the same.

  • State management

    Using States and Reducers to manage Rust’s restrictions on Variables and Mutability

  • Composition

  • Side effects

  • Testing

  • Ergonomics

License

Distributed under the terms of both the MIT license and the Apache License (Version 2.0)

See LICENSE-APACHE and LICENSE-MIT for details.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Why use Composable?

A composable architecture is based around…

Note

If you have already used another unidirectional data flow architecture for application state management, the main take-away is that the State-Reducer pattern is a great fit to Rust’s restrictions on Variables and Mutability:

  • Rust requires mutable references to be unique
  • State mutations may only happen within a Reducer

As for this crate specifically. Features include:

  • Small

    The core functionality is under 2000 lines of code and has minimal dependancies.1

  • Fast

    Store::send takes less than 20 nanoseconds.
    Effects::actions are 5–10× faster.

  • Reliable

    No unsafe code.

Furthermore, the optional async handling is done without dependence on a runtime. A Store runs its Reducer entirely within a single thread. At the same time, Effects make it easy for an application to run code, concurrently or in parallel, that feeds its results back into the appropriate Reducer.

Usage

To use Composable, place the following line under the [dependencies] section in your Cargo.toml:

composable = { version = "0.6", git = "https://github.com/bwoods/Architecture.git" }

Optional Features


  • unstable: enable features that are still heavily under development. Unreleased features include:

    Note that changes to unstable code will never be considered a semver breaking change.

Footnotes

  1. As counted with tokei --exclude src/views/ --exclude examples --exclude benches.

About

Heavily inspired by Point•Free’s Swift Composable Architecture (aka The Composable Architecture)

https://bwoods.github.io/Architecture/

License:Apache License 2.0


Languages

Language:Rust 100.0%