Continuum alternatives and similar libraries
Based on the "EventBus" category.
Alternatively, view Continuum alternatives based on common mentions on social networks and blogs.
-
Bolts
Bolts is a collection of low-level libraries designed to make developing mobile apps easier. -
promises
Promises is a modern framework that provides a synchronization construct for Swift and Objective-C. -
BrightFutures
Write great asynchronous code in Swift using futures and promises -
Hydra
⚡️ Lightweight full-featured Promises, Async & Await Library in Swift -
Bolts-Swift
Bolts is a collection of low-level libraries designed to make developing mobile apps easier. -
Promise
A Promise library for Swift, based partially on Javascript's A+ spec -
SwiftNotificationCenter
A Protocol-Oriented NotificationCenter which is type safe, thread safe and with memory safety -
NoticeObserveKit
NoticeObserveKit is type-safe NotificationCenter wrapper. -
Promis
The easiest Future and Promises framework in Swift. No magic. No boilerplate. -
TopicEventBus
Publish–subscribe design pattern implementation framework, with an ability to publish events by topic. -
FutureLib
FutureLib is a pure Swift 2 library implementing Futures & Promises inspired by Scala. -
Bluebird.swift
Promise/A+, Bluebird inspired, implementation in Swift 5
Appwrite - The Open Source Firebase alternative introduces iOS support
* 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 Continuum or a related project?
README
Continuum
NotificationCenter based Lightweight UI / AnyObject binder.
final class ViewController: UIViewController {
@IBOutlet weak var label: UILabel!
private let viewModel: ViewModel = ViewModel()
private let center = NotificationCenter()
private let bag = ContinuumBag()
override func viewDidLoad() {
super.viewDidLoad()
center.continuum
.observe(viewModel.text, on: .main, bindTo: label, \.text)
.disposed(by: bag)
viewModel.text.value = "Binding this text to label.text!"
}
}
final class ViewModel {
let text: Variable<String>
init() {
self.text = Variable(value: "")
}
}
Usage
1. Observe object KeyPath and bind it to target KeyPath
NotificationCenter's instance has continuum
property. You can access Continuum functions from it.
let center = NotificationCenter()
let observer = center.continuum.observe(viewModel, \.text, on: .main, bindTo: label, \.text)
Above source code means observe viewModel's text propety and bind that value to label's text property on main thread
.
If property is observed, current value comes immediately.
Notify changes with func post(keyPath:)
If value changed, notify changes like this.
viewModel.text = "Changed"
center.continuum.post(keyPath: \ViewModel.text)
print(label.text) // Changed
2. Observe Constant / Variable and bind it to target KeyPath
Constant / Variable are value wrapper. Variable has getter / setter. Constant has only getter.
let center = NotificationCenter()
let text = Variable<String>(value: "")
let observer = center.continuum.observe(text, on: .main, bindTo: label, \.text)
If property is observed, current value comes immediately.
3. Observe Constant / Variable and bind it to closure
Constant / Variable are value wrapper. Variable has getter / setter. Constant has only getter.
let center = NotificationCenter()
let text = Variable<String>(value: "")
let observer = center.continuum.observe(text, on: .main, onValueChange: { value in
// something to do
})
If property is observed, current value comes immediately.
Notify changes with setter of value at Variable
If Variable's value is changed, func post(name:object:)
is automatically executed.
text.value = "Changed"
print(label.text) // Changed
In addition, if Variable's value is changed, related Constant value is automatically changed.
let center = NotificationCenter()
let variable = Variable<String>(value: "")
let constant = Constant<String>(variable: variable)
let observer = center.continuum.observe(constant, on: .main, bindTo: label, \.text)
variable.value = "Changed"
print(label.text) // Changed
Lifecycle of ContinuumObserver
func observe(_:,_:,on:,bindTo:,_:)
returns ContinuumObserver
.
If func cancel()
of ContinuumObserver
called, observation is cancelled.
let observer = center.continuum.observe(viewModel, \.text, on: .main, bindTo: label, \.text)
observer.cancel()
If adding observer to ContinumeBag
, observation is cancelled by lifecycle of ContinumeBag
.
var bag = ContinumeBag()
center.continuum
.observe(viewModel, \.text, on: .main, bindTo: label, \.text)
.disposed(by: bag)
bag = ContinumeBag() // previous instance of ContinumeBag is released and observation is cancelled.
Example
Playground
You can try Continuum with Playground. Open Continuum.xcworkspace and run build. You can try like this.
[](./Images/playground.png)
Example Project
To run the example project, clone the repo, and run pod install
from the Example directory first.
Open ContinuumSample.xcworkspace and run build.
You can try a simple counter app like this.
[](./Images/example.png)
Requirements
- Xcode 9.2 or later
- Swift 4.0.3 or later
- iOS 10.0 or later
Installation
CocoaPods
Continuum is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Continuum'
Carthage
If you’re using Carthage, simply add Continuum to your Cartfile
:
github "marty-suzuki/Continuum"
Author
marty-suzuki, [email protected]
License
Continuum is available under the MIT license. See the LICENSE file for more info.
*Note that all licence references and agreements mentioned in the Continuum README section above
are relevant to that project's source code only.