Can I call Uno function or change Uno properties from FuseJS?
You need to do a wrapper to expose the function.
How?
Example:
public class JSWrapper : NativeModule
{
public JSWrapper () {
AddMember(new NativeFunction("wrapper", (NativeCallback)Wrapper));
}
object Wrapper (Context c, object[] args) {
CallSomeUno();
}
}
UX:
<JSWrapper ux:Global="jsw" />
<JavaScript>
var wrap = require('jsw');
wrap.wrapper();
</JavaScript>
You cannot modify properties on objects declared in UX directly from JS. This is because JS runs on a separate thread.
However, you can data-bind properties in UX to Observable
s in JS, and control them this way. Note that this is not the approprate way to do animation, as communication between JS and UI is not synchronous. Animation should always be done in pure UX markup.
This said, we are working on a new mechanism (not yet released as of 0.9.11) that will allow you to call methods on objects in UX from JS through its script interface. However, this should only be used for one-off commands like .navigateTo()
, .play()
etc, and not for animating properties.
Maybe it’s just me, but I hate that I have no access to ux elements from code. (other then via Observable) Or I have access to them from ux.uno class, but then again I have no access to those methods from FuseJS and vice versa.
This narrows down what I can do. Hopefully that 0.9.11 will give more access.