You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by mo...@apache.org on 2019/08/29 03:04:53 UTC

[incubator-weex] branch master updated: [iOS] add a callback on wxsdkinstance

This is an automated email from the ASF dual-hosted git repository.

moshen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git


The following commit(s) were added to refs/heads/master by this push:
     new dd6a39b  [iOS] add  a callback on wxsdkinstance
     new a5698e3  Merge pull request #2857 from jianhan-he/master
dd6a39b is described below

commit dd6a39bd3259eeab11ad47c203690d35efc60f28
Author: linghe.lh <li...@alibaba-inc.com>
AuthorDate: Wed Aug 28 20:08:02 2019 +0800

    [iOS] add  a callback on wxsdkinstance
---
 ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm |  6 +++++-
 ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h            | 13 +++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm
index ee20118..4d3f4c9 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm
+++ b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm
@@ -226,7 +226,11 @@ WX_EXPORT_METHOD(@selector(resetLoadmore))
         //may be list
         if ([@"scroller" isEqualToString:type]) {
             [weexInstance.apmInstance updateDiffStats:KEY_PAGE_STATS_SCROLLER_NUM withDiffValue:1];
-        }        
+        }
+
+        if (weexInstance.instanceCallback) {
+            weexInstance.instanceCallback(weexInstance, WXScrollerComponentCreatedCallback, self);
+        }
     }
     
     return self;
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
index c28a2d6..dcd4ea5 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
@@ -151,6 +151,10 @@ typedef NS_ENUM(NSInteger, WXErrorCode) {//error.code
     FrameworkVersionErrorCode,
 };
 
+typedef enum : NSUInteger {
+    WXScrollerComponentCreatedCallback
+} WXSDKInstanceCallbackType;
+
 
 @property (nonatomic, assign) WXState state;
 
@@ -226,6 +230,15 @@ typedef NS_ENUM(NSInteger, WXErrorCode) {//error.code
 @property (nonatomic, copy) void (^onScroll)(CGPoint contentOffset);
 
 /**
+ *  The callback of the instance
+ *
+ *  When the callbackType is WXScrollerComponentCreatedCallback, the result type is WXScrollerComponent.
+ *
+ *  @return A block that takes instance, callbackType and a result.
+ **/
+@property (nonatomic, copy) void (^instanceCallback)(WXSDKInstance* instance, WXSDKInstanceCallbackType callbackType, id result);
+
+/**
  * the callback to be run repeatedly while the instance is rendering.
  *
  * @return A block that takes a CGRect argument, which is the rect rendered