Mediator

public class Mediator : NSObject

iOS模块化架构中间件,结合Router可搭建模块化架构设计

支持两种模块加载模式: 模式一:Delegate模式,推荐使用,详见方法:checkAllModules(_:) 模式二:Runtime模式,详见方法:checkAllModules(selector:arguments:)

Bifrost

  • 模块服务加载器,加载未注册模块时会尝试调用并注册,block返回值为register方法module参数

    Declaration

    Swift

    public static let sharedLoader: Loader<Any, any ModuleProtocol.Type>
  • 是否启用Delegate模式,AppResponder.setupEnvironment调用时生效,默认false

    Declaration

    Swift

    public static var delegateModeEnabled: Bool
  • 插件调试描述

    Declaration

    Swift

    public override class func debugDescription() -> String
  • 注册指定模块服务,返回注册结果

    Declaration

    Swift

    @discardableResult
    public static func registerService<T>(_ type: T.Type, module: ModuleProtocol.Type) -> Bool
  • 预置指定模块服务,仅当模块未注册时生效

    Declaration

    Swift

    @discardableResult
    public static func presetService<T>(_ type: T.Type, module: ModuleProtocol.Type) -> Bool
  • 取消注册指定模块服务

    Declaration

    Swift

    public static func unregisterService<T>(_ type: T.Type)
  • 通过服务协议获取指定模块实例

    Declaration

    Swift

    public static func loadModule<T>(_ type: T.Type) -> T?
  • 获取所有已注册模块类数组,按照优先级排序

    Declaration

    Swift

    public static func allRegisteredModules() -> [ModuleProtocol.Type]
  • 初始化所有模块,推荐在willFinishLaunchingWithOptions中调用

    Declaration

    Swift

    public static func setupAllModules()
  • 在UIApplicationDelegate检查所有模块方法,Delegate模式,推荐使用

    Declaration

    Swift

    public static func checkAllModules(_ block: (UIApplicationDelegate) -> Void)
  • 在UIApplicationDelegate检查所有模块方法,Runtime模式

    Declaration

    Swift

    @discardableResult
    public static func checkAllModules(selector: Selector, arguments: [Any]?) -> Bool