FWMediator

@interface FWMediator : NSObject

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

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

    Declaration

    Objective-C

    @property (class, nonatomic, readonly) FWLoader<Protocol *, id> *_Nonnull sharedLoader;
  • 注册指定模块服务,返回注册结果

    Declaration

    Objective-C

    + (BOOL)registerService:(nonnull Protocol *)serviceProtocol
                 withModule:(nonnull Class<FWModuleProtocol>)moduleClass;
  • 预置指定模块服务,仅当模块未注册时生效

    Declaration

    Objective-C

    + (BOOL)presetService:(nonnull Protocol *)serviceProtocol
               withModule:(nonnull Class<FWModuleProtocol>)moduleClass;
  • 取消注册指定模块服务

    Declaration

    Objective-C

    + (void)unregisterService:(nonnull Protocol *)serviceProtocol;
  • 通过服务协议获取指定模块实例

    Declaration

    Objective-C

    + (nullable id<FWModuleProtocol>)loadModule:(nonnull Protocol *)serviceProtocol;
  • 获取所有已注册模块类数组,按照优先级排序

    Declaration

    Objective-C

    + (nonnull NSArray<Class<FWModuleProtocol>> *)allRegisteredModules;
  • 初始化所有模块,推荐在willFinishLaunchingWithOptions中调用

    Declaration

    Objective-C

    + (void)setupAllModules;
  • 在UIApplicationDelegate检查所有模块方法

    Declaration

    Objective-C

    + (BOOL)checkAllModulesWithSelector:(nonnull SEL)selector
                              arguments:(nullable NSArray *)arguments;