All Projects → NoTests → Rxfeedback.swift

NoTests / Rxfeedback.swift

Licence: mit
The universal system operator and architecture for RxSwift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Rxfeedback.swift

Reactorkit
A library for reactive and unidirectional Swift applications
Stars: ✭ 2,237 (+141.06%)
Mutual labels:  rxswift, architecture
Ios Architecture
A collection of iOS architectures - MVC, MVVM, MVVM+RxSwift, VIPER, RIBs and many others
Stars: ✭ 901 (-2.91%)
Mutual labels:  rxswift, architecture
Articles Ios Viper
Demo app for VIPER design pattern implementation
Stars: ✭ 254 (-72.63%)
Mutual labels:  rxswift, architecture
Mvvmc Splitviewcontroller
Example project with UITabBarController inside UISplitViewController using RxSwift and MVVM-C architecture.
Stars: ✭ 45 (-95.15%)
Mutual labels:  rxswift, architecture
Cycle.swift
An experiment in unidirectional architecture inspired by Cycle.js. https://cycle.js.org
Stars: ✭ 24 (-97.41%)
Mutual labels:  rxswift, architecture
Cleanarchitecturerxswift
Example of Clean Architecture of iOS app using RxSwift
Stars: ✭ 3,256 (+250.86%)
Mutual labels:  rxswift, architecture
Coordinator Mvvm Rx Example
Example of MVVM-C architecture implemented with RxSwift
Stars: ✭ 469 (-49.46%)
Mutual labels:  rxswift, architecture
Ios Clean Architecture Mvvm
Template iOS app using Clean Architecture and MVVM. Includes DIContainer, FlowCoordinator, DTO, Response Caching and one of the views in SwiftUI
Stars: ✭ 753 (-18.86%)
Mutual labels:  architecture
Cleanarchitecture
Clean Architecture Solution Template: A starting point for Clean Architecture with ASP.NET Core
Stars: ✭ 8,945 (+863.9%)
Mutual labels:  architecture
Ribs
Uber's cross-platform mobile architecture framework.
Stars: ✭ 6,641 (+615.63%)
Mutual labels:  architecture
Rxautomaton
🤖 RxSwift + State Machine, inspired by Redux and Elm.
Stars: ✭ 711 (-23.38%)
Mutual labels:  rxswift
Artify Core
The sweet heart of Artify 👑
Stars: ✭ 17 (-98.17%)
Mutual labels:  rxswift
Huststore
High-performance Distributed Storage
Stars: ✭ 806 (-13.15%)
Mutual labels:  architecture
Awesome Distributed Systems
A curated list to learn about distributed systems
Stars: ✭ 7,263 (+682.65%)
Mutual labels:  architecture
Quarkus Microservices Poc
Very simplified shop sales system made in a microservices architecture using quarkus
Stars: ✭ 16 (-98.28%)
Mutual labels:  architecture
Rxcombine
Bi-directional type bridging between RxSwift and Apple's Combine framework
Stars: ✭ 741 (-20.15%)
Mutual labels:  rxswift
Androidtddbootstrap
A bootstrap project for TDD Android.
Stars: ✭ 897 (-3.34%)
Mutual labels:  architecture
Github Explorer
Progressive Web Apps experiment
Stars: ✭ 712 (-23.28%)
Mutual labels:  architecture
Mojoc
A cross-platform, open-source, pure C game engine for mobile game.
Stars: ✭ 799 (-13.9%)
Mutual labels:  architecture
Abstractionlayers
Abstraction Layers
Stars: ✭ 16 (-98.28%)
Mutual labels:  architecture

RxFeedback

Travis CI platforms pod Carthage compatible Swift Package Manager compatible

The simplest architecture for RxSwift

    typealias Feedback<State, Event> = (Observable<State>) -> Observable<Event>

    public static func system<State, Event>(
        initialState: State,
        reduce: @escaping (State, Event) -> State,
        feedback: Feedback<State, Event>...
    ) -> Observable<State>

Why

  • Straightforward

    • If it did happen -> Event
    • If it should happen -> Request
    • To fulfill Request -> Feedback loop
  • Declarative

    • System behavior is first declaratively specified and effects begin after subscribe is called => Compile time proof there are no "unhandled states"
  • Debugging is easier

    • A lot of logic is just normal pure function that can be debugged using Xcode debugger, or just printing the commands.
  • Can be applied on any level

    • Entire system
    • application (state is stored inside a database, CoreData, Firebase, Realm)
    • view controller (state is stored inside system operator)
    • inside feedback loop (another system operator inside feedback loop)
  • Works awesome with dependency injection

  • Testing

    • Reducer is a pure function, just call it and assert results
    • In case effects are being tested -> TestScheduler
  • Can model circular dependencies

  • Completely separates business logic from effects (Rx).

    • Business logic can be transpiled between platforms (ShiftJS, C++, J2ObjC)

Examples

Simple UI Feedback loop

Complete example

 Observable.system(
    initialState: 0,
    reduce: { (state, event) -> State in
        switch event {
        case .increment:
            return state + 1
        case .decrement:
            return state - 1
        }
    },
    scheduler: MainScheduler.instance,
    feedback:
        // UI is user feedback
        bind(self) { me, state -> Bindings<Event> in
            let subscriptions = [
                state.map(String.init).bind(to: me.label.rx.text)
            ]

            let events = [
                me.plus.rx.tap.map { Event.increment },
                me.minus.rx.tap.map { Event.decrement }
            ]

            return Bindings(
                subscriptions: subscriptions,
                events: events
            )
        }
)

Play Catch

Simple automatic feedback loop.

Complete example

Observable.system(
    initialState: State.humanHasIt,
    reduce: { (state: State, event: Event) -> State in
        switch event {
        case .throwToMachine:
            return .machineHasIt
        case .throwToHuman:
            return .humanHasIt
        }
    },
    scheduler: MainScheduler.instance,
    feedback:
        // UI is human feedback
        bindUI,
        // NoUI, machine feedback
        react(request: { $0.machinePitching }, effects: { (_) -> Observable<Event> in
            return Observable<Int>
                .timer(1.0, scheduler: MainScheduler.instance)
                .map { _ in Event.throwToHuman }
        })
)

Paging

Complete example

Driver.system(
    initialState: State.empty,
    reduce: State.reduce,
    feedback:
        // UI, user feedback
        bindUI,
        // NoUI, automatic feedback
        react(request: { $0.loadNextPage }, effects: { resource in
            return URLSession.shared.loadRepositories(resource: resource)
                .asSignal(onErrorJustReturn: .failure(.offline))
                .map(Event.response)
        })
)

Run RxFeedback.xcodeproj > Example to find out more.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

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

pod 'RxFeedback', '~> 3.0'

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate RxFeedback into your Xcode project using Carthage, specify it in your Cartfile:

github "NoTests/RxFeedback" ~> 3.0

Run carthage update to build the framework and drag the built RxFeedback.framework into your Xcode project. As RxFeedback depends on RxSwift and RxCocoa you need to drag the RxSwift.framework and RxCocoa.framework into your Xcode project as well.

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding RxFeedback as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/NoTests/RxFeedback.swift.git", majorVersion: 1)
]

Difference from other architectures

  • Elm - pretty close, feedback loops for effects instead of Cmd, which effects to perform are encoded into state and queried by feedback loops
  • Redux - kind of like this, but feedback loops instead of middleware
  • Redux-Observable - observables observe state vs. being inside middleware between view and state
  • Cycle.js - no simple explanation :), ask @andrestaltz
  • MVVM - separates state from effects and doesn't require a view
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].