SSEventFlow 1.3.0

SSEventFlow 1.3.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2020年4月
SPM支持SPM

Simon Strandgaard维护。



SSEventFlow

Version License Platform

SSEventFlow是一个类型安全的替代品,灵感来源于Flux

Flux应用程序架构最近由Facebook发明。 查看如何运作的视频

使用方法

打开SSEventFlow.xcodeproj文件并运行示例项目。

需求

  • iOS 10.0+ / macOS 10.12+
  • Xcode 10+
  • Swift 4.2+

安装

SSEventFlow可通过CocoaPods获得。要安装它,只需将以下行添加到Podfile中:

pod "SSEventFlow"

发送通知的示例

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()
    }
}

监听通知的示例

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 = ""
        }
    }
}

支持

您可免费使用 SSEventFlow。

如果您正在使用并喜欢我的工作,也许您可以考虑赞助我一瓶啤酒(如果您不喝酒——咖啡和百吉饼也行,当然,是想的那种,你知道的……里面满是美妙的东西)。

请通过 PayPal 赞助,就像他们在电视上说的那样——慷慨解囊!这会激励我继续努力。

许可

MIT