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

如何求解问题

如何求解问题

Zbigniew Michalewicz、David B.Fogel / 曹宏庆 / 中国水利水电出版社 / 2003-2-1 / 35.00元

《如何求解问题:现代启发式方法》通过一系列贯穿于章节间的有趣难题,《如何求解问题:现代启发式方法》深入浅出地阐述了如何利用计算机来求解问题的一些现代启发式方法。全书包括两部分,共分15章。一起来看看 《如何求解问题》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器