Skip to content

change template #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions data/console-dir/main-page.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
var vmModule = require("./main-view-model");
/*
In NativeScript, a file with the same name as an XML file is known as
a code-behind file. The code-behind is a great place to place your view
logic, and to set up your page’s data binding.
*/

function pageLoaded(args) {
/*
NativeScript adheres to the CommonJS specification for dealing with
JavaScript modules. The CommonJS require() function is how you import
JavaScript modules defined in other files.
*/
var createViewModel = require("./main-view-model").createViewModel;

function onNavigatingTo(args) {
/*
This gets a reference this page’s <Page> UI component. You can
view the API reference of the Page to see what’s available at
https://docs.nativescript.org/api-reference/classes/_ui_page_.page.html
*/
var page = args.object;
page.bindingContext = vmModule.mainViewModel;

/*
A page’s bindingContext is an object that should be used to perform
data binding between XML markup and JavaScript code. Properties
on the bindingContext can be accessed using the {{ }} syntax in XML.
In this example, the {{ message }} and {{ onTap }} bindings are resolved
against the object returned by createViewModel().

You can learn more about data binding in NativeScript at
https://docs.nativescript.org/core-concepts/data-binding.
*/
page.bindingContext = createViewModel();
console.log("### TEST START ###");

var undef;
Expand Down Expand Up @@ -30,4 +57,11 @@ function pageLoaded(args) {

console.log("### TEST END ###");
}
exports.pageLoaded = pageLoaded;

/*
Exporting a function in a NativeScript code-behind file makes it accessible
to the file’s corresponding XML file. In this case, exporting the onNavigatingTo
function here makes the navigatingTo="onNavigatingTo" binding in this page’s XML
file work.
*/
exports.onNavigatingTo = onNavigatingTo;
45 changes: 38 additions & 7 deletions data/console-log/main-page.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
var vmModule = require("./main-view-model");
/*
In NativeScript, a file with the same name as an XML file is known as
a code-behind file. The code-behind is a great place to place your view
logic, and to set up your page’s data binding.
*/

/*
NativeScript adheres to the CommonJS specification for dealing with
JavaScript modules. The CommonJS require() function is how you import
JavaScript modules defined in other files.
*/
var createViewModel = require("./main-view-model").createViewModel;
var buttonModule = require("tns-core-modules/ui/button");

function pageLoaded(args) {
function onNavigatingTo(args) {
/*
This gets a reference this page’s <Page> UI component. You can
view the API reference of the Page to see what’s available at
https://docs.nativescript.org/api-reference/classes/_ui_page_.page.html
*/
var page = args.object;
page.bindingContext = vmModule.mainViewModel;

/*
A page’s bindingContext is an object that should be used to perform
data binding between XML markup and JavaScript code. Properties
on the bindingContext can be accessed using the {{ }} syntax in XML.
In this example, the {{ message }} and {{ onTap }} bindings are resolved
against the object returned by createViewModel().

You can learn more about data binding in NativeScript at
https://docs.nativescript.org/core-concepts/data-binding.
*/
page.bindingContext = createViewModel();
console.log("### TEST START ###");
console.time("Time");

Expand All @@ -21,7 +48,6 @@ function pageLoaded(args) {
}

console.log(very_long_string);

console.log(true);
console.log(false);
console.log(null);
Expand All @@ -34,7 +60,6 @@ function pageLoaded(args) {
console.log(`number: ${num}`);
console.log(`string: ${str}`);
console.log(`${str} ${num}`);

console.info("info");
console.warn("warn");
console.error("error");
Expand All @@ -45,7 +70,6 @@ function pageLoaded(args) {
console.assert("", "empty string evaluates to 'false'");

console.trace("console.trace() called");

console.log(`${button}`);

console.log(num, str, obj);
Expand All @@ -56,4 +80,11 @@ function pageLoaded(args) {
console.timeEnd("Time");
console.log("### TEST END ###");
}
exports.pageLoaded = pageLoaded;

/*
Exporting a function in a NativeScript code-behind file makes it accessible
to the file’s corresponding XML file. In this case, exporting the onNavigatingTo
function here makes the navigatingTo="onNavigatingTo" binding in this page’s XML
file work.
*/
exports.onNavigatingTo = onNavigatingTo;
1 change: 1 addition & 0 deletions data/folders/feature1/feature1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("I was here")
43 changes: 43 additions & 0 deletions data/folders/main-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
In NativeScript, a file with the same name as an XML file is known as
a code-behind file. The code-behind is a great place to place your view
logic, and to set up your page’s data binding.
*/

/*
NativeScript adheres to the CommonJS specification for dealing with
JavaScript modules. The CommonJS require() function is how you import
JavaScript modules defined in other files.
*/
var createViewModel = require("./main-view-model").createViewModel;
var count = 0;

function onNavigatingTo(args) {
/*
This gets a reference this page’s <Page> UI component. You can
view the API reference of the Page to see what’s available at
https://docs.nativescript.org/api-reference/classes/_ui_page_.page.html
*/
var page = args.object;

/*
A page’s bindingContext is an object that should be used to perform
data binding between XML markup and JavaScript code. Properties
on the bindingContext can be accessed using the {{ }} syntax in XML.
In this example, the {{ message }} and {{ onTap }} bindings are resolved
against the object returned by createViewModel().

You can learn more about data binding in NativeScript at
https://docs.nativescript.org/core-concepts/data-binding.
*/
page.bindingContext = createViewModel();
console.log("Page loaded " + ++count + " times.");
}

/*
Exporting a function in a NativeScript code-behind file makes it accessible
to the file’s corresponding XML file. In this case, exporting the onNavigatingTo
function here makes the navigatingTo="onNavigatingTo" binding in this page’s XML
file work.
*/
exports.onNavigatingTo = onNavigatingTo;
Loading