weex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinji...@apache.org
Subject [24/50] [abbrv] incubator-weex git commit: * [ios] ensure default modules/components/handlers are ready before create instance.
Date Tue, 24 Jan 2017 08:21:35 GMT
* [ios] ensure default modules/components/handlers are ready before create instance.


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/fdf5ed75
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/fdf5ed75
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/fdf5ed75

Branch: refs/heads/master
Commit: fdf5ed7533a15ff7126322a052bbf288cf249b87
Parents: 9b6f726
Author: 隐风 <cxfeng1@gmail.com>
Authored: Wed Jan 11 11:33:55 2017 +0800
Committer: 隐风 <cxfeng1@gmail.com>
Committed: Wed Jan 11 11:33:55 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.h  |  7 ++++++-
 ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m  | 14 +++++++++++---
 ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m |  4 ++++
 3 files changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/fdf5ed75/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.h b/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.h
index 691573d..ad2f742 100644
--- a/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.h
+++ b/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.h
@@ -13,7 +13,12 @@
 @interface WXSDKEngine : NSObject
 
 /**
- *  @abstract Registers a module for a given name
+ *  @abstract Register default modules/components/handlers, they will be reigstered only
once.
+ **/
++ (void)registerDefaults;
+
+/**
+ *  @abstract Register a module for a given name
  *
  *  @param name The module name to register
  *

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/fdf5ed75/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m b/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
index 642cabc..a23e03e 100644
--- a/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
+++ b/ios/sdk/WeexSDK/Sources/Engine/WXSDKEngine.m
@@ -208,13 +208,21 @@
         return;
     }
     
-    [self _registerDefaultComponents];
-    [self _registerDefaultModules];
-    [self _registerDefaultHandlers];
+    [self registerDefaults];
     
     [[WXSDKManager bridgeMgr] executeJsFramework:script];
 }
 
++ (void)registerDefaults
+{
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        [self _registerDefaultComponents];
+        [self _registerDefaultModules];
+        [self _registerDefaultHandlers];
+    });
+}
+
 + (NSString*)SDKEngineVersion
 {
     return WX_SDK_VERSION;

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/fdf5ed75/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
index 50901bc..fd5a53b 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@ -25,6 +25,7 @@
 #import "WXResourceRequest.h"
 #import "WXResourceResponse.h"
 #import "WXResourceLoader.h"
+#import "WXSDKEngine.h"
 
 NSString *const bundleUrlOptionKey = @"bundleUrl";
 
@@ -173,6 +174,9 @@ typedef enum : NSUInteger {
         }
     });
     
+    // ensure default modules/components/handlers are ready before create instance
+    [WXSDKEngine registerDefaults];
+    
     [[WXSDKManager bridgeMgr] createInstance:self.instanceId template:mainBundleString options:dictionary
data:_jsData];
     
     WX_MONITOR_PERF_SET(WXPTBundleSize, [mainBundleString lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
self);


Mime
View raw message