Skip to content

Commit

Permalink
refactor: move _invokeMethodFromJavaScript to KrakenMethodChannel's s…
Browse files Browse the repository at this point in the history
…tatic method
  • Loading branch information
andycall authored and yuanyan committed May 8, 2021
1 parent b835863 commit f4be5ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion kraken/lib/src/launcher/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ class KrakenController {
}

_methodChannel = methodChannel;
setJSMethodCallCallback(this);
KrakenMethodChannel.setJSMethodCallCallback(this);

_view = KrakenViewController(viewportWidth, viewportHeight,
background: background,
Expand Down
16 changes: 8 additions & 8 deletions kraken/lib/src/module/method_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ class MethodChannelModule extends BaseModule {
}
}

void setJSMethodCallCallback(KrakenController controller) {
if (controller.methodChannel == null) return;

controller.methodChannel._onJSMethodCall = (String method, dynamic arguments) async {
controller.module.moduleManager.emitModuleEvent(METHOD_CHANNEL_NAME, data: [method, arguments]);
};
}

class KrakenMethodChannel {
MethodCallCallback _onJSMethodCallCallback;

Expand All @@ -55,6 +47,14 @@ class KrakenMethodChannel {
}

Future<dynamic> _invokeMethodFromJavaScript(String method, List arguments) async {}

static void setJSMethodCallCallback(KrakenController controller) {
if (controller.methodChannel == null) return;

controller.methodChannel._onJSMethodCall = (String method, dynamic arguments) async {
controller.module.moduleManager.emitModuleEvent(METHOD_CHANNEL_NAME, data: [method, arguments]);
};
}
}

class KrakenJavaScriptChannel extends KrakenMethodChannel {
Expand Down

0 comments on commit f4be5ce

Please sign in to comment.