All Projects → keitaoouchi → Fluxxkit

keitaoouchi / Fluxxkit

Licence: mit
Unidirectional data flow for reactive programming in iOS.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Fluxxkit

Vueflux
♻️ Unidirectional State Management Architecture for Swift - Inspired by Vuex and Flux
Stars: ✭ 315 (+650%)
Mutual labels:  reactive-programming, unidirectional-data-flow, flux
SwiftObserver
Elegant Reactive Primitives for Clean Swift Architecture #NoRx
Stars: ✭ 14 (-66.67%)
Mutual labels:  rxswift, reactive-programming
assembler
Functional, type-safe, stateless reactive Java API for efficient implementation of the API Composition Pattern for querying/merging data from multiple datasources/services, with a specific focus on solving the N + 1 query problem
Stars: ✭ 102 (+142.86%)
Mutual labels:  flux, reactive-programming
Cycle.swift
An experiment in unidirectional architecture inspired by Cycle.js. https://cycle.js.org
Stars: ✭ 24 (-42.86%)
Mutual labels:  rxswift, unidirectional-data-flow
Rxflow
RxFlow is a navigation framework for iOS applications based on a Reactive Flow Coordinator pattern
Stars: ✭ 1,589 (+3683.33%)
Mutual labels:  reactive-programming, rxswift
Combinerxswiftperformance
A test suite comparing the performance of Combine and RxSwift
Stars: ✭ 154 (+266.67%)
Mutual labels:  reactive-programming, rxswift
Mp3ID3Tagger
🎶🎵A macOS application to edit the ID3 tag of your mp3 files. Developed with RxSwift and RxCocoa. 🎸🎼
Stars: ✭ 17 (-59.52%)
Mutual labels:  rxswift, reactive-programming
Rxswiftext
A collection of Rx operators & tools not found in the core RxSwift distribution
Stars: ✭ 1,080 (+2471.43%)
Mutual labels:  reactive-programming, rxswift
Verge
🟣 Verge is a very tunable state-management engine on iOS App (UIKit / SwiftUI) and built-in ORM.
Stars: ✭ 273 (+550%)
Mutual labels:  rxswift, flux
Cleanarchitecturerxswift
Example of Clean Architecture of iOS app using RxSwift
Stars: ✭ 3,256 (+7652.38%)
Mutual labels:  reactive-programming, rxswift
Kunidirectional
The goal of this sample app is to show how we can implement unidirectional data flow architecture based on Flux and Redux on Android... using Kotlin 😉
Stars: ✭ 303 (+621.43%)
Mutual labels:  unidirectional-data-flow, flux
Rerxswift
ReRxSwift: RxSwift bindings for ReSwift
Stars: ✭ 97 (+130.95%)
Mutual labels:  reactive-programming, rxswift
Spring 5 Examples
This repository is contains spring-boot 2 / spring framework 5 project examples. Using reactive programming model / paradigm and Kotlin
Stars: ✭ 87 (+107.14%)
Mutual labels:  reactive-programming, flux
WhatFilm
Simple iOS app using TMDb API and RxSwift
Stars: ✭ 35 (-16.67%)
Mutual labels:  rxswift, reactive-programming
Rxexamples
Tests with RxSwift by book of Ray Wenderlich
Stars: ✭ 66 (+57.14%)
Mutual labels:  reactive-programming, rxswift
ballade
For unidirectional data flow.
Stars: ✭ 44 (+4.76%)
Mutual labels:  flux, unidirectional-data-flow
Rxstate
Redux implementation in Swift using RxSwift
Stars: ✭ 142 (+238.1%)
Mutual labels:  rxswift, unidirectional-data-flow
Rxswift To Combine Cheatsheet
RxSwift to Apple’s Combine Cheat Sheet
Stars: ✭ 1,040 (+2376.19%)
Mutual labels:  reactive-programming, rxswift
Swiftrex
Swift + Redux + (Combine|RxSwift|ReactiveSwift) -> SwiftRex
Stars: ✭ 267 (+535.71%)
Mutual labels:  reactive-programming, rxswift
Rxswift
RxSwift를 스터디하는 공간
Stars: ✭ 335 (+697.62%)
Mutual labels:  reactive-programming, rxswift

FluxxKit

CI Status Swift 4.0 Carthage compatible Version License Platform

Overview

Unidirectional data flow for reactive programming in iOS. Flux and Reactive Programming.

FluxxKit is a porting facebook's flux implementation in Swift.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

More complicated real world example like below is here.

GIF

Getting Started

  1. State
import FluxxKit
import RxSwift

final class ViewModel: StateType {
  var count = Variable<Int>(0)
}
  1. Action
extension ViewModel {
  enum Action: ActionType {
    case plus
    case minus
  }
}
  1. Reducer
extension ViewModel {
  final class Reducer: FluxxKit.Reducer<ViewModel, Action> {
    override func reduce(state: ViewModel, action: Action) {

      switch action {
      case .plus:
        state.count.value = state.count + 1
      case .minus:
        state.count.value = state.count - 1
      }
    }
  }
}
  1. View

Create store and register it to dispatcher, and bind store's state:

import FluxxKit
import RxSWift

final class ViewController: UIViewController {

  @IBOutlet var counterLabel: UILabel!
  @IBOutlet var plusButton: UIButton!
  @IBOutlet var minusButton: UIButton!
  var store = Store<ViewModel, ViewModel.Action>(
    reducer: ViewModel.Reducer()
  )

  override func viewDidLoad() {
    super.viewDidLoad()

    Dispatcher.shared.register(store: self.store)

    store.state.count.asObservable().observeOn(MainScheduler.instance)
      .subscribe(onNext: { [weak self] count in
        self?.counterLabel.text = "\(count)"
      })
  }

  deinit {
    Dispatcher.shared.unregister(identifier: self.store.identifier)
  }
}

Dispatch action with UI action:

@IBAction
func onTouchPlusButton(sender: Any) {
  Dispatcher.shared.dispatch(action: ViewModel.Action.plus)
}

@IBAction
func onTouchMinusButton(sender: Any) {
  Dispatcher.shared.dispatch(action: ViewModel.Action.minus)
}

Architecture

(👻 nice diagram here 👻)

FLUX for Reactive Programming

FluxxKit would not emit any event when state change like flux. Instead, we have RxSwift, ReactiveSwift, ReactiveKit or something else. All the stateful things could be implemented as Observable or Stream, and ViewController could bind and react to them.

Flux

View -> Action -> Dispatcher -> (Middleware) -> Store -> Reducer -> Observable
  • When a user interacts with a View(Controller), it propagates an Action
  • through a central Dispatcher,
  • to the various Stores that hold the application's data,
  • state transition occurs in some Store that could responds to dispatched Action,
  • which will emit new items to Observable property in these Store.

Reactive Programming

Observable ---> View
  • ViewController subscribes Store's Observable properties,
  • and react to it.

Requirements

Target Version
iOS => 8.0
Swift => 4.0

Installation

FluxxKit is available through CocoaPods or Carthage.

CocoaPods

pod "FluxxKit"

Carthage

github "keitaoouchi/FluxxKit"

for detail, please follow the Carthage Instruction

Author

keitaoouchi, [email protected]

License

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

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].