All Projects → nalexn → minimalist

nalexn / minimalist

Licence: MIT license
Observable Property and Signal for building data-driven UI without Rx

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to minimalist

SwiftObserver
Elegant Reactive Primitives for Clean Swift Architecture #NoRx
Stars: ✭ 14 (-84.09%)
Mutual labels:  observer, rxswift, observer-pattern
Rxiglistkit
RxSwift wrapper for IGListKit
Stars: ✭ 44 (-50%)
Mutual labels:  rxswift, data-driven
Datasources
💾 🔜📱 Type-safe data-driven CollectionView, TableView Framework. (We can also use ASCollectionNode)
Stars: ✭ 553 (+528.41%)
Mutual labels:  rxswift, data-driven
Moyamapper
快速解析模型工具,支持RxSwift。同时支持缓存功能 【相关手册 https://MoyaMapper.github.io 】
Stars: ✭ 115 (+30.68%)
Mutual labels:  rxswift, rx
RxBatteryManager
A Reactive BatteryManager in Swift for iOS
Stars: ✭ 21 (-76.14%)
Mutual labels:  rxswift, rx
RxEureka
This library is a small RxSwift wrapper around Eureka
Stars: ✭ 37 (-57.95%)
Mutual labels:  rxswift, rx
Lightweightobservable
📬 A lightweight implementation of an observable sequence that you can subscribe to.
Stars: ✭ 114 (+29.55%)
Mutual labels:  observer, rx
Rxmarvel
Playing around marvel public API with RxSwift, Argo, Alamofire
Stars: ✭ 86 (-2.27%)
Mutual labels:  rxswift, rx
Signalkit
SignalKit is a reactive Swift framework with focus on clean and readable API.
Stars: ✭ 245 (+178.41%)
Mutual labels:  observer, signal
Moya
Network abstraction layer written in Swift.
Stars: ✭ 13,607 (+15362.5%)
Mutual labels:  rxswift, reactiveswift
Moya-Gloss
Gloss bindings for Moya
Stars: ✭ 37 (-57.95%)
Mutual labels:  rxswift, reactiveswift
Rxswift
Reactive Programming in Swift
Stars: ✭ 21,163 (+23948.86%)
Mutual labels:  observer, rxswift
RacJS
implementation of RAC(OC) on JavaScript and replacement of RxJS
Stars: ✭ 13 (-85.23%)
Mutual labels:  rx, signal
Verge
🟣 Verge is a very tunable state-management engine on iOS App (UIKit / SwiftUI) and built-in ORM.
Stars: ✭ 273 (+210.23%)
Mutual labels:  rxswift, data-driven
Combinerxswiftperformance
A test suite comparing the performance of Combine and RxSwift
Stars: ✭ 154 (+75%)
Mutual labels:  rxswift, rx
state inspector
State change & method call logger. A debugging tool for instance variables and method calls.
Stars: ✭ 24 (-72.73%)
Mutual labels:  observer, observer-pattern
Rxstorekit
StoreKit library for RxSwift
Stars: ✭ 96 (+9.09%)
Mutual labels:  observer, rxswift
Laravel Auditing
Record the change log from models in Laravel
Stars: ✭ 2,210 (+2411.36%)
Mutual labels:  observer
laravel-attribute-observer
Observe (and react to) attribute changes made on Eloquent models.
Stars: ✭ 59 (-32.95%)
Mutual labels:  observer
Pydesignpattern
Design Pattern that described by Python, This is the source code for the book of Everybody Know Design Patterns.
Stars: ✭ 174 (+97.73%)
Mutual labels:  observer

Minimalist

Build Status Coverage Status

Building data-driven UI without Rx


I'm a big fan of reactive frameworks. I've used RxSwift, ReactiveSwift, Combine, and I suffer every time I join the project where the team cannot adopt one for some reason.

  • Problem #1: Teams beware the complexity and steep learning curve
  • Problem #2: Traditional frameworks are too bulky for small projects

This library is a take on cutting off everything non-essential. In fact, all you need to build the data-driven UI is observable property and event broadcaster. And that's all that you get with this micro-framework (just 100 lines of code):

@Property

Also known as:

  • BehaviorRelay in RxSwift
  • MutableProperty in ReactiveSwift
  • CurrentValueSubject in Combine
class ViewModel {
    @Property var items: [Items] = []
}

// Access the current value:
viewModel.items.count

// Subscribe on changes of the value:
viewModel.$items.observe(with: self) { (obj, items) in
    ...
}

@Signal

Also known as:

  • PublishRelay in RxSwift
  • Signal in ReactiveSwift
  • PassthroughSubject in Combine
class ViewModel {
    @Signal var didReceiveMessage: Accepts<Message>
}

// Broadcast a notification:
didReceiveMessage.send(message)

// Subscribe on updates:
viewModel.$didReceiveMessage.observe(with: self) { (obj, message) in
    ...
}

Features

Access control

You can restrict the write access from outside of the module using just Swift's access control:

class ViewModel {
    @Property private(set) var value: String = "Minimalist"
    @Signal private(set) var signal: Accepts<Void>
}

// Cannot change property or trigger a signal:
viewModel.value = "abc" //
viewModel.signal.send(()) //

Automatic memory management

Subscription is bound to the lifetime of the supplied object and gets detached automatically. That object is also provided in the callback along with the value, so you don't need to do the [weak self] dance all the time:

class ViewController: UIViewController {
    var tableView: UITableView
    
    func viewDidLoad() {
        ...
        viewModel.$items.observe(with: self) { (vc, items) in
            vc.tableView.reloadData()
        }
    }
}

Filter state updates (Redux)

Data-driven UI works best with unidirectional data flow design, which may involve using a centralized state in the app.

Upon subscription, you can specify the KeyPath to the value inside the state container to receive scoped and filtered updates (like with distinctUntilChanged):

$appState.observe(\.screens.loginScreen, with: self) { (obj, state) in
    ...
}

Pro Tip: \.self is also a valid KeyPath. This way you can discard the same values while observing a primitive type.

Installation

@ Carthage

github "nalexn/minimalist"

@ CocoaPods

pod 'Minimalist'

@ SPM

.package(url: "https://github.com/nalexn/minimalist.git", from: "1.0.0")

blog venmo

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