iOS: optimize hot reload operation which causes render error
This commit is contained in:
parent
61e537aa98
commit
f4fcb981b4
@ -107,18 +107,22 @@ - (void)build:(CGSize)size {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)reload:(NSString *)script {
|
- (void)reload:(NSString *)script {
|
||||||
[self.driver destroyContext:self.contextId];
|
[[self.driver destroyContext:self.contextId] waitUntilResult];
|
||||||
self.rootNode.viewId = nil;
|
self.rootNode.viewId = nil;
|
||||||
[self.rootNode clearSubModel];
|
[self.rootNode clearSubModel];
|
||||||
[self.rootNode.view.subviews forEach:^(__kindof UIView *obj) {
|
[self.rootNode.view.subviews forEach:^(__kindof UIView *obj) {
|
||||||
[obj removeFromSuperview];
|
[obj removeFromSuperview];
|
||||||
}];
|
}];
|
||||||
self.script = script;
|
self.script = script;
|
||||||
[self.driver createContext:self.contextId script:script source:self.source];
|
_destroyed = YES;
|
||||||
[self init:self.extra];
|
[self dispatchToMainQueue:^{
|
||||||
[self callEntity:DORIC_ENTITY_CREATE withArgumentsArray:@[]];
|
_destroyed = NO;
|
||||||
[self callEntity:DORIC_ENTITY_BUILD withArgumentsArray:@[self.initialParams]];
|
[self.driver createContext:self.contextId script:script source:self.source];
|
||||||
[self onShow];
|
[self init:self.extra];
|
||||||
|
[self callEntity:DORIC_ENTITY_CREATE withArgumentsArray:@[]];
|
||||||
|
[self callEntity:DORIC_ENTITY_BUILD withArgumentsArray:@[self.initialParams]];
|
||||||
|
[self onShow];
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)onShow {
|
- (void)onShow {
|
||||||
|
@ -41,7 +41,7 @@ - (instancetype)initWithContext:(DoricContext *)context callbackId:(NSString *)c
|
|||||||
|
|
||||||
- (void)resolve:(id)result {
|
- (void)resolve:(id)result {
|
||||||
__weak typeof(self) __self = self;
|
__weak typeof(self) __self = self;
|
||||||
if (self.context == nil) {
|
if (self.context == nil || self.context.destroyed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
[[self.context.driver invokeDoricMethod:DORIC_BRIDGE_RESOLVE
|
[[self.context.driver invokeDoricMethod:DORIC_BRIDGE_RESOLVE
|
||||||
@ -58,7 +58,7 @@ - (void)resolve:(id)result {
|
|||||||
|
|
||||||
- (void)reject:(id)result {
|
- (void)reject:(id)result {
|
||||||
__weak typeof(self) __self = self;
|
__weak typeof(self) __self = self;
|
||||||
if (self.context == nil) {
|
if (self.context == nil || self.context.destroyed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
[[self.context.driver invokeDoricMethod:DORIC_BRIDGE_REJECT
|
[[self.context.driver invokeDoricMethod:DORIC_BRIDGE_REJECT
|
||||||
|
Reference in New Issue
Block a user