I’m trying to implement this recent code input component as a separate class and grab its value in my own component, like this:
<SegmentedInput Label="Enter your code" />
<TextInput PlaceholderText="Enter the password" Value="{password}" />
And in my js file:
var Observable = require("FuseJS/Observable");
var MyService = require("Services/MyService");
var SegmentedInput = require("Components/SegmentedInput");
var url = "http://someURL";
var password = Observable("");
function login() {
MyService.loginService(url, SegmentedInput.code.value, password.value)
.then(function(result) {
console.log(result);
});
}
module.exports = {
password: password,
login: login
}
I saw a video from Jake teaching how to organize the JS files in a Fuse project and expose them as a Bundle and then call it with the “require” method (just like the code above), but I noticed that it doesn’t work with Observables, only with simple variables.
My question is: How can I get the value of the “code” Observable (as in the tutorial) in my own component since all the logic is encapsulated inside the SegmentedInput Class?
And second, use it from MainView.ux (or any other UX file) like this:
<App>
<float4 ux:Global="Highlight" ux:Value="#999" />
<JavaScript>
var Observable = require("FuseJS/Observable");
var theCode = Observable("");
// I am only adding the following to see how the code changes.
// you can read theCode.value when you call a submit() function or something similar
theCode.onValueChanged(module, function(x) {
console.log("theCode changed to: " + x);
});
module.exports = {
theCode: theCode
};
</JavaScript>
<ClientPanel>
<SegmentedInput Label="Enter Code" Code="{theCode}" Alignment="Top" Margin="16,64,16,0" />
</ClientPanel>
</App>