install-b / DelegateCenter

一个面向协议的通知中心

Home Page:https://github.com/install-b

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DelegateCenter

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

subscript protocol

/// Protocol Way
// declare Protocol
@objc protocol XXXProtocol {
    func aMethod()
}

// on subscribe
DelegateCenter.default.add(self as XXXProtocol)

// cancel subscribe
DelegateCenter.default.remove(self as XXXProtocol)



// send message
DelegateCenter.default.enumDelegate(XXXProtocol.self) { (delegate, _) in
    delegate.aMethod()
}
        
/// Abstract Class Way
// declare Abstract Class
class AClass {
    open func aMethod() {

    }
}

/// 
class SubAClass: AClass {
    overrite func aMethod() {
        // sub Class implemention
    }
}

let aInstance = SubAClass()
DelegateCenter.default.add(aInstance as AClass)


// send message
DelegateCenter.default.enumDelegate(AClass.self) { (delegate, _) in
    delegate.aMethod()
}
        

Requirements

Installation

DelegateCenter is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'DelegateCenter'

Author

install-b, 645256685@qq.com

License

DelegateCenter is available under the MIT license. See the LICENSE file for more info.

About

一个面向协议的通知中心

https://github.com/install-b

License:MIT License


Languages

Language:Swift 91.1%Language:Objective-C 4.7%Language:Ruby 4.2%