zoukankan      html  css  js  c++  java
  • WeexSDK之注册Handlers

    先看代码:

    + (void)_registerDefaultHandlers
    {
        [self registerHandler:[WXResourceRequestHandlerDefaultImpl new] withProtocol:@protocol(WXResourceRequestHandler)];
        [self registerHandler:[WXNavigationDefaultImpl new] withProtocol:@protocol(WXNavigationProtocol)];
        [self registerHandler:[WXURLRewriteDefaultImpl new] withProtocol:@protocol(WXURLRewriteProtocol)];
        
    }

    WXSDKEngine中默认注册了3个Handler。

    + (void)registerHandler:(id)handler withProtocol:(Protocol *)protocol
    {
        WXAssert(handler && protocol, @"Fail to register the handler, please check if the parameters are correct !");
        
        [WXHandlerFactory registerHandler:handler withProtocol:protocol];
    }

    WXSDKEngine会继续调用WXHandlerFactory的registerHandler:withProtocol:方法。

    @interface WXHandlerFactory : NSObject
    
    @property (nonatomic, strong) WXThreadSafeMutableDictionary *handlers;
    
    + (void)registerHandler:(id)handler withProtocol:(Protocol *)protocol;
    
    + (id)handlerForProtocol:(Protocol *)protocol;
    
    + (NSDictionary *)handlerConfigs;
    
    @end

    WXHandlerFactory也是一个单例,里面有一个线程安全的字典handlers,用来保存实例和Protocol名的映射表。

     

  • 相关阅读:
    英语阅读重点单词总结
    Redis 应用
    Python 列表[::-1]翻转
    golang数据类型
    golang变量
    k8s 容器控制台日志收集
    css显示模式
    css选择器
    css样式引入
    GIL锁
  • 原文地址:https://www.cnblogs.com/LeeGof/p/9019112.html
Copyright © 2011-2022 走看看