initChannelFunctions method
void
initChannelFunctions(
)
override
Implementation
@override
void initChannelFunctions() {
JavascriptRuntime.channelFunctionsRegistered[getEngineInstanceId()] = {};
final setToGlobalObject =
evaluate("(key, val) => { this[key] = val; }").rawResult;
(setToGlobalObject as JSInvokable).invoke([
'sendMessage',
(String channelName, String message) {
final channelFunctions = JavascriptRuntime
.channelFunctionsRegistered[getEngineInstanceId()]!;
if (channelFunctions.containsKey(channelName)) {
return channelFunctions[channelName]!.call(jsonDecode(message));
} else {
print('No channel $channelName registered');
}
if (JavascriptRuntime.debugEnabled) {
print('CHANNEL: $channelName - Message: $message');
}
}
]);
}