Recently, I delved into the world of native-script framework and decided to dive into the "Get Started with JavaScript" tutorial provided on their official website. My background in Java has made me more comfortable with typescript, so I attempted to swap out all JavaScript code with its typescript counterpart.
Everything was going smoothly until I hit Chapter three > 3.4: Adding a view model section, where I found myself puzzled about how to implement Observable in typescript. The example code from the website looked like this:
var observableModule = require("data/observable");
var user = new observableModule.fromObject({
email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="97e2e4f2e5d7f3f8faf6fef9b9f4f8fa">[email protected]</a>",
password: "password"
});
This prompted me to come up with my own solution:
import {Observable} from 'data/observable';
class User extends Observable {
email = "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aadfd9cfd8eacec5c7cbc3c484c9c5c7">[email protected]</a>";
password = "password";
}
let user = new User();
Upon testing, my version seemed to function correctly. Can someone confirm if these codes are equivalent or if I missed something?