All Projects → gokselkoksal → Core

gokselkoksal / Core

Licence: MIT license
Starter kit for Core architecture.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to Core

Zero Fux
No Flux plus no Redux equals ZeroFux. A stateless unidirectional data flow implemented with Custom Events.
Stars: ✭ 37 (-46.38%)
Mutual labels:  unidirectional-data-flow
Rxstate
Redux implementation in Swift using RxSwift
Stars: ✭ 142 (+105.8%)
Mutual labels:  unidirectional-data-flow
Knot
Unidirectional reactive state container for Android & Kotlin
Stars: ✭ 198 (+186.96%)
Mutual labels:  unidirectional-data-flow
Reduxpaperswift
A simple approach to learning the beginnings of Redux in Swift.
Stars: ✭ 65 (-5.8%)
Mutual labels:  unidirectional-data-flow
Reactivereswift
Unidirectional Data Flow in Swift via FRP - Inspired by Elm
Stars: ✭ 133 (+92.75%)
Mutual labels:  unidirectional-data-flow
Remvvm
ReMVVM is an application architecture concept, marriage of Unidirectional Data Flow (Redux) with MVVM.
Stars: ✭ 168 (+143.48%)
Mutual labels:  unidirectional-data-flow
Reswift
Unidirectional Data Flow in Swift - Inspired by Redux
Stars: ✭ 7,054 (+10123.19%)
Mutual labels:  unidirectional-data-flow
Kaskade
[INACTIVE] Simplifying state management
Stars: ✭ 223 (+223.19%)
Mutual labels:  unidirectional-data-flow
Mvi Coroutines Flow
Play MVI with Kotlin Coroutines Flow | MVI pattern on Android using Kotlin Coroutines Flow | Dagger Hilt DI | Koin DI | SharedFlow | StateFlow
Stars: ✭ 133 (+92.75%)
Mutual labels:  unidirectional-data-flow
Render
UIKit a-là SwiftUI.framework [min deployment target iOS10]
Stars: ✭ 2,150 (+3015.94%)
Mutual labels:  unidirectional-data-flow
Aftermath
🔮 Stateless message-driven micro-framework in Swift.
Stars: ✭ 67 (-2.9%)
Mutual labels:  unidirectional-data-flow
Awesome Tca
Awesome list for The Composable Architecture
Stars: ✭ 124 (+79.71%)
Mutual labels:  unidirectional-data-flow
Uniflow Polymer
UniFlow for Polymer
Stars: ✭ 168 (+143.48%)
Mutual labels:  unidirectional-data-flow
Fluxxkit
Unidirectional data flow for reactive programming in iOS.
Stars: ✭ 42 (-39.13%)
Mutual labels:  unidirectional-data-flow
Viw
VI Worsened, a lightweight and fun VI clone.
Stars: ✭ 212 (+207.25%)
Mutual labels:  unidirectional-data-flow
Swiftea
Bits of the Elm Architecture in Swift for iOS, MacOS and SwiftUI
Stars: ✭ 32 (-53.62%)
Mutual labels:  unidirectional-data-flow
Reactivefeedback
Unidirectional reactive architecture
Stars: ✭ 156 (+126.09%)
Mutual labels:  unidirectional-data-flow
knot
Unidirectional reactive state container for Android & Kotlin
Stars: ✭ 231 (+234.78%)
Mutual labels:  unidirectional-data-flow
Movies Usf Android
Movie searching using a Unidirectional State Flow pattern for Android
Stars: ✭ 222 (+221.74%)
Mutual labels:  unidirectional-data-flow
Reactor
🔄 Unidirectional data flow in Swift.
Stars: ✭ 174 (+152.17%)
Mutual labels:  unidirectional-data-flow

Core

Carthage CocoaPods CI Status Platform Language License

Core helps you design applications in a way that the app flow is driven by business layer, instead of UI layer. It also promotes unidirectional data flow between components for consistency, high testability and powerful debugging.

Related Article: Architecting iOS Apps with "Core"

Design

Class Diagram

  • Core is simply a box that represents our app.
  • Components are our features.
  • Actions are the changes that happen on the system.
  • Subscribers can be anything. It can be a console app. It can be an iOS app. It can be our test suite.

Core can be seen as a Redux, Flux and MVVM hybrid.

Main differences between Core and Redux:

  • Redux is static. It expects you to define a big fat structure that expresses the app state in compile time. This can be challenging if you have reusable controllers that you present here and there a number of times. Especially in cases where your application flow is altered by server responses, you cannot easily define your app state in compile time without hacking the architecture. Core is dynamic. You only need to define the state and actions for the component you are working on. Transition between components is handled dynamically.

  • In Redux, there is no standard way to implement navigation between components. With Core, you get native navigation support.

  • Redux focuses on application state, whereas Core focuses on isolated component state. In this regard, I find it easier to work in isolation on one component rather than getting lost in huge application state.

  • In Redux, since the state is global, it’s easy to forget to do state clean-up when a screen is popped from the navigation stack. In Core, since every component stores its own state, when you remove a component from the tree, state gets disposed along with it. This is handled internally by navigation mechanism.

Implementation

I'll follow the tradition and start with countdown example.

State:

struct CountdownState: State {
  var count: UInt
}

Actions:

enum CountdownAction: Action {
  case tick
}

Component:

class CountdownComponent: Component<CountdownState> {
  
  func process(action: Action) {
    guard let action = action as? LoginAction else { return }
    switch action {
    case .tick:
      tick()
    }
  }
  
  private func tick() {
    var state = state 
    state.count = state.count - 1
    if state.count == 0 {
      let nextComponent = ResultComponent()
      let navigation = BasicNavigation.push(nextComponent, from: self)
      commit(state, navigation)
    } else {
      commit(state)
    }
  }
}

More complex examples:

Installation

Using CocoaPods

Add the following line to your Podfile:

pod 'CoreArchitecture'

Using Carthage

Add the following line to your Cartfile:

github "gokselkoksal/Core"

Manually

Drag and drop Sources folder to your project.

It's highly recommended to use a dependency manager like CocoaPods or Carthage.

Alternatives

You can also check out ReSwift, Reactor or Dispatch for pure Redux and Flux implementations for Swift.

License

Core is available under the MIT license.

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