Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neoneye/SSEventFlow
SSEventFlow is a type safe alternative to NotificationCenter, inspired by Flux
https://github.com/neoneye/SSEventFlow
flux nsnotifications swift
Last synced: 3 months ago
JSON representation
SSEventFlow is a type safe alternative to NotificationCenter, inspired by Flux
- Host: GitHub
- URL: https://github.com/neoneye/SSEventFlow
- Owner: neoneye
- License: mit
- Created: 2016-02-20T22:32:17.000Z (almost 9 years ago)
- Default Branch: develop
- Last Pushed: 2020-04-11T12:10:41.000Z (almost 5 years ago)
- Last Synced: 2024-09-21T19:45:15.297Z (4 months ago)
- Topics: flux, nsnotifications, swift
- Language: Swift
- Homepage:
- Size: 46.9 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-swift-cn - SSEventFlow - A type safe alternative to NSNotification, inspired by Flux. (Libs / Events)
README
# SSEventFlow
[![Version](https://img.shields.io/cocoapods/v/SSEventFlow.svg?style=flat)](http://cocoapods.org/pods/SSEventFlow)
[![License](https://img.shields.io/cocoapods/l/SSEventFlow.svg?style=flat)](http://cocoapods.org/pods/SSEventFlow)
[![Platform](https://img.shields.io/cocoapods/p/SSEventFlow.svg?style=flat)](http://cocoapods.org/pods/SSEventFlow)SSEventFlow is a type safe alternative to NotificationCenter, inspired by Flux.
The Flux Application Architecture was recently invented by Facebook.
[See video to how it works](https://facebook.github.io/flux/docs/in-depth-overview)## Usage
Open the `SSEventFlow.xcodeproj` file and run the Example project.
## Requirements
- iOS 13.0+ / macOS 10.15+
- Xcode 11.4+
- Swift 5.2+## Installation
SSEventFlow is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod "SSEventFlow"
```## Example of how to send out notifications
```swift
class ParentViewController: UIViewController {
@IBAction func redButtonAction(_ sender: Any) {
PickedColorEvent(color: UIColor.red, name: "RED").fire()
}
@IBAction func greenButtonAction(_ sender: Any) {
PickedColorEvent(color: UIColor.green, name: "GREEN").fire()
}
@IBAction func blueButtonAction(_ sender: Any) {
PickedColorEvent(color: UIColor.blue, name: "BLUE").fire()
}
@IBAction func resetButtonAction(_ sender: Any) {
ResetEvent().fire()
}
}
```## Example of how to listen for notifications
```swift
class ChildViewController: UIViewController {
@IBOutlet weak var colorName: UILabel!
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
flow_start()
}
override func viewDidDisappear(_ animated: Bool) {
flow_stop()
super.viewDidDisappear(animated)
}
}extension ChildViewController: FlowDispatcher {
func flow_dispatch(_ event: FlowEvent) {
if let e = event as? PickedColorEvent {
view.backgroundColor = e.color
colorName.text = e.name
}
if event is ResetEvent {
view.backgroundColor = nil
colorName.text = ""
}
}
}
```# Support
You are welcome to use SSEventFlow free of charge.
If you are using and enjoying my work, maybe you could donate me a beer (or if you don’t drink –
a coffee and bagel will do just fine, a good kind of bagel though, you know… with wonderful stuff inside to make it glorious).[Please donate via PayPal](https://paypal.me/SimonStrandgaard) and just like they say on TV – give generously! It motivates me to keep working on this.
# License
MIT