CommandBus

码农软件 · 软件分类 · 其他(Others) · 2019-07-18 12:58:24

软件介绍

一个轻量级的 Command Bus 的实现,用 Swift 编写。

使用:

{
    "{CommandNameA}": "{CommandHandlerNameA}",
    "{CommandNameB}": "{CommandHandlerNameB}",
    "{CommandNameC}": "{CommandHandlerNameC}"
}
class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        /*** Register to the Command event ***/
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "onCommandHandled:", name:"COMMAND_DONE", object: nil)
        /*** Create the CommandBus ***/
        let commandBus: CommandBus = CommandBus(configurationFileName: "configuration")!
        /*** Create your own CommandHandler ***/
        let customCommand: CustomCommand = CustomCommand()
        /*** Send your commandHandler to the CommandBus with your event name ***/
        commandBus.handle(command: customCommand, commandHandledEvent: "COMMAND_DONE")
    }
    func onCommandHandled(notification: NSNotification) {
        /*** This method is called when the CommandHandler have done ***/
        print("Command Handled: \(notification.object!)")
    }
}


本文地址:https://codercto.com/soft/d/10400.html

Learn Python 3 the Hard Way

Learn Python 3 the Hard Way

Zed A. Shaw / Addison / 2017-7-7 / USD 30.74

You Will Learn Python 3! Zed Shaw has perfected the world’s best system for learning Python 3. Follow it and you will succeed—just like the millions of beginners Zed has taught to date! You bring t......一起来看看 《Learn Python 3 the Hard Way》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

SHA 加密
SHA 加密

SHA 加密工具