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

Commit

Permalink
[WEEX-262][iOS] Add new interface of Instance,which will terminate re…
Browse files Browse the repository at this point in the history
…nder process after bundleJS download finished.
  • Loading branch information
boboning committed Mar 22, 2018
1 parent 83d2543 commit 40c6c19
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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

0 comments on commit 40c6c19

Please sign in to comment.