You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2018/02/09 11:28:12 UTC

incubator-weex git commit: [WEEX-200][iOS] deprecate wxcallback and wxmodulecallback

Repository: incubator-weex
Updated Branches:
  refs/heads/master 784903132 -> 36a3f268b


[WEEX-200][iOS] deprecate wxcallback and wxmodulecallback

As iOS  developers knows, we cannot distinguish the block by its params count, but it has been a time we use the default value of block parameter, I find out  that the default value could be dirty data.

here is the callback type  definition.

typedef void (^WXCallback)(_Nonnull id result)

typedef void (^WXKeepAliveCallback)(_Nonnull id result, BOOL keepAlive);

when the method called, weexSDK will set the callback according to the @encode result,

but these two type's encode result are all "?", see more encode result from Apple Documents https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html

Bug:200
close #1000


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

Branch: refs/heads/master
Commit: 36a3f268b9f67d9505e6cad454934a2670e2b42c
Parents: 7849031
Author: acton393 <zh...@gmail.com>
Authored: Tue Jan 23 16:51:29 2018 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri Feb 9 19:27:43 2018 +0800

----------------------------------------------------------------------
 ios/playground/WeexDemo/extend/module/WXEventModule.m | 4 ++--
 ios/sdk/WeexSDK/Sources/Model/WXComponent.h           | 2 +-
 ios/sdk/WeexSDK/Sources/Protocol/WXModuleProtocol.h   | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/36a3f268/ios/playground/WeexDemo/extend/module/WXEventModule.m
----------------------------------------------------------------------
diff --git a/ios/playground/WeexDemo/extend/module/WXEventModule.m b/ios/playground/WeexDemo/extend/module/WXEventModule.m
index 59e9158..1cebd62 100644
--- a/ios/playground/WeexDemo/extend/module/WXEventModule.m
+++ b/ios/playground/WeexDemo/extend/module/WXEventModule.m
@@ -55,12 +55,12 @@ WX_EXPORT_METHOD(@selector(fireNativeGlobalEvent:callback:))
  a test method for macaca case, you can fire globalEvent when download finish、device shaked and so on.
  @param event event name
  */
-- (void)fireNativeGlobalEvent:(NSString *)event callback:(WXModuleCallback)callback
+- (void)fireNativeGlobalEvent:(NSString *)event callback:(WXKeepAliveCallback)callback
 {
     [weexInstance fireGlobalEvent:event params:@{@"eventParam":@"eventValue"}];
     if (callback) {
         NSDictionary * result = @{@"ok": @true};
-        callback(result);
+        callback(result,false);
     }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/36a3f268/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
index ac1b13a..92f1e34 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.h
@@ -32,7 +32,7 @@ typedef enum : NSUInteger {
  * @abstract the component callback , result can be string or dictionary.
  * @discussion callback data to js, the id of callback function will be removed to save memory.
  */
-typedef void (^WXCallback)(_Nonnull id result);
+typedef void (^WXCallback)(_Nonnull id result) DEPRECATED_MSG_ATTRIBUTE("use WXKeepAliveCallback, you can specify keep the callback or not, if keeped, it can be called multi times, or it will be removed after called.");
 
 /**
  * @abstract the component callback , result can be string or dictionary.

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/36a3f268/ios/sdk/WeexSDK/Sources/Protocol/WXModuleProtocol.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Protocol/WXModuleProtocol.h b/ios/sdk/WeexSDK/Sources/Protocol/WXModuleProtocol.h
index a6bab03..6ea275c 100644
--- a/ios/sdk/WeexSDK/Sources/Protocol/WXModuleProtocol.h
+++ b/ios/sdk/WeexSDK/Sources/Protocol/WXModuleProtocol.h
@@ -34,7 +34,7 @@
  * @abstract the module callback , result can be string or dictionary.
  * @discussion callback data to js, the id of callback function will be removed to save memory.
  */
-typedef void (^WXModuleCallback)(id result);
+typedef void (^WXModuleCallback)(id result) DEPRECATED_MSG_ATTRIBUTE("use WXModuleKeepAliveCallback, you can specify keep the callback or not, if keeped, it can be called multi times, or it will be removed after called.");
 
 /**
  * @abstract the module callback , result can be string or dictionary.