TopicEventBus alternatives and similar libraries
Based on the "Events" category.
Alternatively, view TopicEventBus alternatives based on common mentions on social networks and blogs.
-
ReactiveCocoa
Cocoa framework and Obj-C dynamism bindings for ReactiveSwift. -
ReactorKit
A library for reactive and unidirectional Swift applications -
OpenCombine
Open source implementation of Apple's Combine framework for processing values over time. -
Katana
Swift Apps in a Swoosh! A modern framework for creating iOS apps, inspired by Redux. -
BrightFutures
Write great asynchronous code in Swift using futures and promises -
SwiftEventBus
A publish/subscribe EventBus optimized for iOS -
FutureKit
A Swift based Future/Promises Library for IOS and OS X. -
PMKVObserver
Modern thread-safe and type-safe key-value observing for Swift and Objective-C -
Tempura
A holistic approach to iOS development, inspired by Redux and MVVM -
VueFlux
:recycle: Unidirectional State Management Architecture for Swift - Inspired by Vuex and Flux -
When
:alarm_clock: A lightweight implementation of Promises in Swift -
SignalKit
SignalKit is a reactive Swift framework with focus on clean and readable API. -
NoticeObserveKit
NoticeObserveKit is type-safe NotificationCenter wrapper. -
RxReduce
Reactive implementation of the state container pattern (like Redux). It is based on the simple concepts of state immutability and unidirectionnal data flow. -
LightweightObservable
📬 A lightweight implementation of an observable sequence that you can subscribe to. -
Notificationz
📡 Helping you own NotificationCenter in Swift! -
Aftermath
:crystal_ball: Stateless message-driven micro-framework in Swift. -
OneWay
A Swift library for state management with unidirectional data flow. -
SSEventFlow
SSEventFlow is a type safe alternative to NotificationCenter, inspired by Flux -
Causality
A simple thread-safe, in-memory bus for Swift that supports fully-typed Events and States.
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 TopicEventBus or a related project?
README
TopicEventBus
Publish–subscribe design pattern implementation framework, with ability to publish events by topic. (NotificationCenter extended alternative)
About:
TopicEventBus is Easy to use, type safe way of implementing Publish–subscribe design pattern.
There are many other libraries out there, aiming to solve this issue, but none of them support publishing events by topic, in a type-safe way, with no magic strings.
Also, TopicEventBus holds weak referenced for Its observers, so you don't have to be afraid of memory leaks.
What is a topic?
The topic is for example, when you would like to publish "ConversationUpdateEvent" yet have the ability to publish that event only to listeners with conversation id "1234" or to all listeners.
Specifying the conversation Id is specifying a topic for that event.
Show me the code! and what's in it for me.
Let's build a chat app!
In this app, we are going to have multiple conversations screens, each one of them would like to know only about changes to Its conversation.
The first step, create an event for conversation update:
class ConversationChangedEvent: TopicEvent {
let newTitle: String
init(conversationId: String, newTitle: String) {
self.newTitle = newTitle
super.init()
self.key = conversationId
}
}
Every event must inherit from "TopicEvent," and in case it has a topic (Our example it will be the conversation id) set "key" property to the correct value.
Now inside ConversationVC, subscribe to this event:
Notice you only need to specify the return value you are expecting, for TopicEventBus to figure out the event you are subscribing for
class ConversationVC: UIViewController {
let topicEventBus: TopicEventBus
let conversationId = "1234"
init(topicEventBus: TopicEventBus) {
self.topicEventBus = topicEventBus
}
override func viewDidLoad() {
super.viewDidLoad()
_ = self.topicEventBus.subscribe(topic: conversationId, callback: { (conversationChangedEvent: ConversationChangedEvent) in
// This will run every time "ConversationChangedEvent" with id 1234 will be fired.
})
}
}
This is how you fire an event:
class FiringService {
let topicEventBus: TopicEventBus
init(topicEventBus: TopicEventBus) {
self.topicEventBus = topicEventBus
}
func conversationTitleChanged() {
self.topicEventBus.fire(event: ConversationChangedEvent.init(conversationId: "1234",
newTitle: "First update"))
}
}
You did it! You fired your first event with topic 🤗 🎉
API
If you subscribe to event and specify no topic, you will receive all events from that type, no matter their key:
_ = self.topicEventBus.subscribe { (conversationChangedEvent: ConversationChangedEvent) in
// All events from this type: ConversationChangedEvent will trigger this block
}
Unsubscribe by calling "stop" on the returned object after subscribing:
let listener = self.topicEventBus.subscribe(topic: conversationId, callback: { (conversationChangedEvent: ConversationChangedEvent) in
//
})
listener.stop()
On app log out, terminate TopicEventBus by just calling:
self.topicEventBus.terminate()
Example project
Please notice example project contains tests to support all edge cases, plus example code from the above snippets.
Installation
Cocoapods
TopicEventBus is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'TopicEventBus'
Manually
- Download and drop
/TopicEventBus
folder in your project. - Congratulations!
Author
Matan made this with ❤️.