import { UniUTSJS } from 'DCloudUniappRuntime' import { NSNumber } from 'Foundation'; let MessageChannel : string = "UtsMessage" var revFromJS = "" export function getMessageChannel() : string { return MessageChannel } export function getRevJsMessage() : string { return revFromJS } export function emitUtsMessage(arg : string) { uni.$emit(MessageChannel, arg); } var callbackId : NSNumber | null = null export function onJsMessage (messageChannel : string ) { revFromJS = "" if (callbackId != null) { uni.$off(messageChannel, callbackId!) callbackId = null } callbackId = uni.$on(messageChannel, function (...spreadArgs : Any) { if (spreadArgs.length > 0) { let arg0 = spreadArgs[0] as String | null if ( arg0 != null ){ revFromJS = arg0!; } } }) } export function onJsMessageOnce (messageChannel : string ) { revFromJS = "" uni.$once(messageChannel, function (...spreadArgs : Any) { if (spreadArgs.length > 0) { let arg0 = spreadArgs[0] as String | null if ( arg0 != null ){ revFromJS = arg0!; } } }) } export function offJsMessage(messageChannel : string) { if (callbackId != null) { uni.$off(messageChannel, callbackId!) } } export function clearJsMessage() { revFromJS = "" }