As the doc(https://developer.garmin.com/connect-iq/monkey-c/functions/#Callbacks) says, function can be transmited as callback, The transmitation works, but the callback cannot be stored in a "var" variable.
Demo as follows:
/*************AppView***************/
class AppView extends WatchUi.View {
protected var myClassInst;
function initialize() {
View.initialize();
myClassInst= new MyClass(method(:requestUpdate)); // works, an object having "mMethod:requestUpdate" is transmitted
}
}
/*************MyClass***************/
class MyClass{
private var _theCallback;
protected var tickTimer;
function initialize(callbackFun) {
_theCallback=callbackFun; // according to the debug info, "callbackFun" value is the same as transmitted, but "_theCallback" shows "not available"
tickTimer.start(method(:tickTimerCallback), 1000, true); // start a timer to invoke callback functions
}
function tickTimerCallback() {
(_theCallback&& _theCallback.invoke()); // "_theCallback" shows "not available" too, and the update requested not occurs
}
}
Appreciated for your answer !