Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[iOS] add a callback on wxsdkinstance
Browse files Browse the repository at this point in the history
  • Loading branch information
jianhan-he committed Aug 28, 2019
1 parent af7c957 commit dd6a39b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ -(instancetype)initWithRef:(NSString *)ref type:(NSString *)type styles:(NSDicti
//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;
Expand Down
13 changes: 13 additions & 0 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ typedef NS_ENUM(NSInteger, WXErrorCode) {//error.code
FrameworkVersionErrorCode,
};

typedef enum : NSUInteger {
WXScrollerComponentCreatedCallback
} WXSDKInstanceCallbackType;


@property (nonatomic, assign) WXState state;

Expand Down Expand Up @@ -225,6 +229,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.
*
Expand Down

0 comments on commit dd6a39b

Please sign in to comment.