Bindy alternatives and similar libraries
Based on the "Reactive Programming" category.
Alternatively, view Bindy alternatives based on common mentions on social networks and blogs.
-
OpenCombine
Open source implementation of Apple's Combine framework for processing values over time. -
Tokamak
DISCONTINUED. SwiftUI-compatible framework for building browser apps with WebAssembly and native apps for other platforms [Moved to: https://github.com/TokamakUI/Tokamak] -
Katana
DISCONTINUED. Swift Apps in a Swoosh! A modern framework for creating iOS apps, inspired by Redux. -
Interstellar
DISCONTINUED. Simple and lightweight Functional Reactive Coding in Swift for the rest of us. :large_orange_diamond: -
Verge
๐ฃ A robust Swift state-management framework designed for complex applications, featuring an integrated ORM for efficient data handling. -
VueFlux
:recycle: Unidirectional State Management Architecture for Swift - Inspired by Vuex and Flux -
RxReduce
DISCONTINUED. Lightweight framework that ease the implementation of a state container pattern in a Reactive Programming compliant way. -
LightweightObservable
๐ฌ A lightweight implementation of an observable sequence that you can subscribe to. -
ReactiveArray
An array class implemented in Swift that can be observed using ReactiveCocoa's Signals -
STDevRxExt
STDevRxExt contains some extension functions for RxSwift and RxCocoa which makes our live easy. -
RxAlamoRecord
RxAlamoRecord combines the power of the AlamoRecord and RxSwift libraries to create a networking layer that makes interacting with API's easier than ever reactively.
SaaSHub - Software Alternatives and Reviews
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Bindy or a related project?
README
Bindy
Just a simple bindings.
Installation
Add
pod 'Bindy'
to your podfile, and run
pod install
Usage
For now, Bindy has a couple of basic types
- Signal - allows triggering a callback when some signal received.
- Observable - allows observing changing of value.
- ObservableArray - conforms to MutableCollection protocol, so you can work with it like with a regular array: subscript index, replace objects, map, enumerate, etc... Also, ObservableArray has
updates
signal, which will notify you about any changes in the array, such as insert, replace, delete.
Observables Sample
let firstname = Observable("Salvador")
let age = Observable(54)
func setupBindings() {
age.bind(self) { [unowned self] newAge in
print("Happy \(newAge) birthday, \(self.firstname.value)")
}
age.value = 55
}
Don't forget always use [unowned owner]
in closure to prevent the retain cycle.
Signal and Array Sample
let messages: ObservableArray<Message> = []
let newMessage = Signal<Message>()
func setupBindings() {
newMessage.bind(self) { [unowned self] message in
self.messages.append(message)
}
messages.updates.bind(self) { [unowned tableView] updates in
self.tableView.pefrom(updates: updates)
}
}
func handleDidRecieveMessage(_ message: Message) {
newMessage.send(message)
}
}
You don't need to remove binding manually if you don't want. When the object that you pass as owner in bind(_ owner: AnyObject...
method deallocates, corresponding bindings will clean. However, if you want to unbind manually, just call unbind(_ owner: AnyObject)
.
Bindy has an extension for tableView for performing updates tableView.perform(updates:...
Also, observables have a method observe(_ owner: AnyObject...
, it works like bind
, but triggers callback immediately, this may be more comfortable in some situations.
Transformations
If you want to receive events with transformed type, you can use transform
function on Observables like:
let speed = Observable(20)
lazy var speedString = speed.transform { "\($0)km/h" }
func setupBindings() {
speedString.observe(self) { [unowned self] speedString in
// speedString = "20km/h"
self.speedLabel.text = speedString
}
}
Combinations
You can combine two Observable types with combined(with: ..., transform: ...)
function like:
let firstname = Observable("Maxim")
let lastname = Observable("Kotliar")
let age = Observable(24)
lazy var fullName = firstname
.combined(with: lastname) { "name: \($0) \($1)" }
.combined(with: age) { "\($0), age: \($1)" }
func setupBindings() {
userInfo.observe(self) { [unowned self] info in
// info = "name: Maxim Kotliar, age:24"
self.userInfoLabel.text = info
}
}
For Observable<Bool>
combinations Bindy have more convenient operators &&
and ||
, so you can combine Observable<Bool>
like regular Bool, also you can invert it with !
:
let isPremiumPurchased = Observable(true)
let isInTrialPeriodEnded = Observable(false)
let isAdsShowForced = Observable(false)
lazy var shouldShowAds = isAdsShowForced || !isPremiumPurchased && isInTrialPeriodEnded
KVO support
Bindy supports KVO, so you can create Observable
from any KVO capable property with easy subscript syntax like:
let textField = UITextField()
let text = textField[\.text] // type will be Observable<String?>
text.observe(self) { newText in
print(newText)
}
Old value
For any Observable
type you can receive old value in closure, just pass two parameters to binding closure, first one will be an old value, the second one โ new value:
let observableString = Observable("test")
observableString.bind(self) { oldString, newString in
print("String changed from \(oldString) to \(newString)")
}
High order functions
Bindy contains some high order functions:
map
- applies on any type, behavior similar to a swift map.flatMap
- applies on Observable with optional type, returns Signal with non-optional type.compactMap
- applies on Observable with Collection inside, behavior similar to a swift version of the function.reduce
- applies on Observable with Collection inside, behavior similar to a swift version of the function.filter
- applies on Observable with Collection inside, behavior similar to a swift version of the function.
*Note that all licence references and agreements mentioned in the Bindy README section above
are relevant to that project's source code only.