Caesura

master

Modularization Library in Swift - Powered by ReSwift
LucianoPolit/Caesura

Banner

Build Coverage Swift Package Manager compatible CocoaPods compatible Gitter chat

Index

Features

Unidirectional Data Flow

Inherited from ReSwift.

ReSwift is a Redux-like implementation of the unidirectional data flow architecture in Swift. ReSwift helps you to separate three important concerns of your app's components:

  • State: in a ReSwift app the entire app state is explicitly stored in a data structure. This helps avoid complicated state management code, enables better debugging and has many, many more benefits...
  • Views: in a ReSwift app your views update when your state changes. Your views become simple visualizations of the current app state.
  • State Changes: in a ReSwift app you can only perform state changes through actions. Actions are small pieces of data that describe a state change. By drastically limiting the way state can be mutated, your app becomes easier to understand and it gets easier to work with many collaborators.

Go to the repository for more information.

Modularization

In order to use ReSwift, you have to declare a state, a reducer and a store. Then, in most of the cases, the state ends up being spread all around the app, meaning that it's hard to keep the modules as decoupled as you probably want.

That's when Caesura comes in handy. It encapsulates the state, reducer and store in such way that your only concern is to develop the modules, without them depending on each other. All of that without loosing the capability to stop the app at any moment and get to know the state of the entire app.

So, a simple app would look like:

Check out the usage documentation for more information.

Navigation Router

There is a built-in module based on actions that is as flexible as UIKit is.

Check out the usage documentation for more information.

Time Travel

Have you ever dreamed about traveling back and forth in time? Well, it's not possible yet. But your app can easily do it with an optional built-in module.

Check out the usage documentation for more information.

Crash Tracking

An optional built-in module is capable of detecting crashes and reporting them. Each report contains all the actions dispatched to the store. Therefore, you can replay the exactly same session and discover the reason of such event easily.

Check out the usage documentation for more information.

Session Injection

The last feature wasn't complete without a way of injecting such report without having to do it manually. There is another optional built-in module capable of such thing.

Check out the usage documentation for more information.

ReRxSwift Integration

There is also an optional built-in module to bring the benefits of ReRxSwift into Caesura.

Similar to react-redux, ReRxSwift allows you to create view controllers that have props and actions. View controllers read all data they need from their props (instead of directly from the state), and they change data by invoking callbacks defined by actions (instead of directly dispatching ReSwift actions). This has some nice advantages:

  • Better separation of concerns. It is easier to understand what your view controller does and what data it uses. In other words, it facilitates local reasoning.
  • Unit-testing. Because of the separation of concerns, you can easily unit-test your view controllers, all the way up to the Interface Builder connections.
  • Better reusability. Reusing your view controllers is as simple as specifying different mappings from state to props and from ReSwift actions to actions.
  • Rapid prototyping. You can easily use dummy props and actions so that you get a working UI layer prototype. Without writing any of your application's business logic, you can implement your presentation layer in such a way that it is very simple to replace the dummies with real state and actions.

Check out the usage documentation for more information.

Requirements

  • Xcode 10.0+
  • Swift 5.0+

Installation

Swift Package Manager

To integrate Caesura into your project using Swift Package Manager, specify it in your Package.swift:

// swift-tools-version:5.0

import PackageDescription

let package = Package(
    name: "YourPackageName",
    dependencies: [
        .package(
            url: "https://github.com/LucianoPolit/Caesura.git",
            .upToNextMajor(from: "1.0.0-rc")
        )
    ],
    targets: [
        .target(
            name: "YourTarget",
            dependencies: [
                "Caesura",
                "CaesuraUI",
                "CaesuraStandardAction",
                "CaesuraMiddlewares",
                "ReRxCaesura"
            ]
        )
    ]
)

CocoaPods

To integrate Caesura into your project using CocoaPods, specify it in your Podfile:

pod 'Caesura', '~> 1.0.0-rc'
pod 'Caesura/Core', '~> 1.0.0-rc'
pod 'Caesura/UI', '~> 1.0.0-rc'
pod 'Caesura/StandardAction', '~> 1.0.0-rc'
pod 'Caesura/Middlewares', '~> 1.0.0-rc'
pod 'Caesura/ReRxSwift', '~> 1.0.0-rc'

Communication

Author

Luciano Polit | lucianopolit@gmail.com

License

Caesura is available under the MIT license. See the LICENSE file for more info.

Description

  • Swift Tools 5.0.0

Dependencies

Last updated: Mon Sep 21 2020 11:27:21 GMT-0500 (GMT-05:00)