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

[WEEX-262][iOS] Add new interface of Instance,which will terminate re… #1079

Merged
merged 1 commit into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ typedef NS_ENUM(NSInteger, WXErrorCode) {//error.code
*/
@property (nonatomic, copy) void(^onJSDownloadedFinish)(WXResourceResponse *response,WXResourceRequest *request,NSData *data, NSError* error);

/**
* The callback triggered when the bundleJS request finished in the renderWithURL. If the callback returns YES, the render process will terminate.
* @return A block that takes response which the server response,request which send to server,data which the server returned and an error
*/
@property (nonatomic, copy) BOOL (^onRenderTerminateWhenJSDownloadedFinish)(WXResourceResponse *response,WXResourceRequest *request,NSData *data, NSError* error);


/**
* the frame of current instance.
**/
Expand Down
6 changes: 6 additions & 0 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ - (void)_renderWithRequest:(WXResourceRequest *)request options:(NSDictionary *)
WX_MONITOR_SUCCESS_ON_PAGE(WXMTJSDownload, strongSelf.pageName);
WX_MONITOR_INSTANCE_PERF_END(WXPTJSDownload, strongSelf);

if (strongSelf.onRenderTerminateWhenJSDownloadedFinish) {
if (strongSelf.onRenderTerminateWhenJSDownloadedFinish(response, request, data, error)) {
return;
}
}

[strongSelf _renderWithMainBundleString:jsBundleString];
[WXTracingManager setBundleJSType:jsBundleString instanceId:weakSelf.instanceId];
};
Expand Down