feat:add InjectEmpty to ignore too much logout

This commit is contained in:
pengfei.zhou 2019-11-26 13:32:07 +08:00
parent 9a9482eeb5
commit 208c635b8b
6 changed files with 15 additions and 2 deletions

View File

@ -96,6 +96,12 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
return null; return null;
} }
}); });
mDoricJSE.injectGlobalJSFunction(DoricConstant.INJECT_EMPTY, new JavaFunction() {
@Override
public JavaValue exec(JSDecoder[] args) {
return null;
}
});
mDoricJSE.injectGlobalJSFunction(DoricConstant.INJECT_REQUIRE, new JavaFunction() { mDoricJSE.injectGlobalJSFunction(DoricConstant.INJECT_REQUIRE, new JavaFunction() {
@Override @Override
public JavaValue exec(JSDecoder[] args) { public JavaValue exec(JSDecoder[] args) {

View File

@ -31,6 +31,7 @@ public class DoricConstant {
public static final String INJECT_TIMER_SET = "nativeSetTimer"; public static final String INJECT_TIMER_SET = "nativeSetTimer";
public static final String INJECT_TIMER_CLEAR = "nativeClearTimer"; public static final String INJECT_TIMER_CLEAR = "nativeClearTimer";
public static final String INJECT_BRIDGE = "nativeBridge"; public static final String INJECT_BRIDGE = "nativeBridge";
public static final String INJECT_EMPTY = "nativeEmpty";
public static final String TEMPLATE_CONTEXT_CREATE = "Reflect.apply(" + public static final String TEMPLATE_CONTEXT_CREATE = "Reflect.apply(" +
"function(doric,context,Entry,require,exports){" + "\n" + "function(doric,context,Entry,require,exports){" + "\n" +

View File

@ -59,7 +59,9 @@ - (void)initJSExecutor {
[self.jsExecutor injectGlobalJSObject:INJECT_LOG obj:^(NSString *type, NSString *message) { [self.jsExecutor injectGlobalJSObject:INJECT_LOG obj:^(NSString *type, NSString *message) {
DoricLog(@"JS:%@", message); DoricLog(@"JS:%@", message);
}]; }];
[self.jsExecutor injectGlobalJSObject:INJECT_EMPTY obj:^() {
}];
[self.jsExecutor injectGlobalJSObject:INJECT_REQUIRE obj:^(NSString *name) { [self.jsExecutor injectGlobalJSObject:INJECT_REQUIRE obj:^(NSString *name) {
__strong typeof(_self) self = _self; __strong typeof(_self) self = _self;
if (!self) return NO; if (!self) return NO;

View File

@ -32,6 +32,7 @@ extern NSString *const INJECT_REQUIRE;
extern NSString *const INJECT_TIMER_SET; extern NSString *const INJECT_TIMER_SET;
extern NSString *const INJECT_TIMER_CLEAR; extern NSString *const INJECT_TIMER_CLEAR;
extern NSString *const INJECT_BRIDGE; extern NSString *const INJECT_BRIDGE;
extern NSString *const INJECT_EMPTY;
extern NSString *const TEMPLATE_CONTEXT_CREATE; extern NSString *const TEMPLATE_CONTEXT_CREATE;

View File

@ -32,6 +32,7 @@
NSString *const INJECT_TIMER_SET = @"nativeSetTimer"; NSString *const INJECT_TIMER_SET = @"nativeSetTimer";
NSString *const INJECT_TIMER_CLEAR = @"nativeClearTimer"; NSString *const INJECT_TIMER_CLEAR = @"nativeClearTimer";
NSString *const INJECT_BRIDGE = @"nativeBridge"; NSString *const INJECT_BRIDGE = @"nativeBridge";
NSString *const INJECT_EMPTY = @"nativeEmpty";
NSString *const TEMPLATE_CONTEXT_CREATE = @"Reflect.apply(" NSString *const TEMPLATE_CONTEXT_CREATE = @"Reflect.apply("
"function(doric,context,Entry,require,exports){" "\n" "function(doric,context,Entry,require,exports){" "\n"

View File

@ -31,6 +31,8 @@ export function NativeCall(target: Panel, propertyKey: string, descriptor: Prope
type Frame = { width: number, height: number } type Frame = { width: number, height: number }
declare function nativeEmpty(): void
export abstract class Panel { export abstract class Panel {
context?: any context?: any
onCreate() { } onCreate() { }
@ -132,7 +134,7 @@ export abstract class Panel {
private hookAfterNativeCall() { private hookAfterNativeCall() {
//Here insert a native call to ensure the promise is resolved done. //Here insert a native call to ensure the promise is resolved done.
log('Check Dirty') nativeEmpty()
if (this.__root__.isDirty()) { if (this.__root__.isDirty()) {
const model = this.__root__.toModel() const model = this.__root__.toModel()
this.nativeRender(model) this.nativeRender(model)