Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Use the [NativeScript CLI](http://www.telerik.com/forums/using-the-cli-to-build-
Read the advanced topics below or refer to the [Api Reference](ApiReference/) to build a powerful NativeScript application:

- [Application](application-management.md)
- [Layouts](layouts.md)
- [Navigation](navigation.md)
- [Layouts](layouts.md)
- [Styling](styling.md)
- [Binding](bindings.md)
- [UI with XML](ui-with-xml.md)
Expand Down
74 changes: 43 additions & 31 deletions application-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,19 @@ nav-title: "Application Management"
title: "Application Management"
description: "Application Management"
position: 2
---

# Persist and Restore Application Settings
To persist settings that the user has defined you have to use the local-settings module. The local-settings module is a static singleton hash table that stores key-value pairs for the application. The getter methods have two parameters -- a key and an optional default value to return if the specified key does not exist. The setter methods also have two parameters -- key and value. Here is an example of using the local settings-module and all of its available methods:
---
# Application Start
You are required to call the **start** method of the application module once you are ready with its initialization. This method doesn't do anything for an Android application at the moment but may do in the future. In an iOS application this call will start the UIApplication and will trigger its UI message loop.:
``` JavaScript
var localSettings = require("local-settings");
// Event handler for Page "loaded" event attached in main-page.xml
function pageLoaded(args) {
localSettings.setString("Name", "John Doe");
console.log(localSettings.getString("Name")); // Prints "John Doe"
localSettings.setBoolean("Married", false);
console.log(localSettings.getBoolean("Married")); // Prints false
localSettings.setNumber("Age", 42);
console.log(localSettings.getNumber("Age")); // Prints 42
console.log(localSettings.hasKey("Name")); // Prints true
localSettings.remove("Name"); // Removes the Name entry.
console.log(localSettings.hasKey("Name")); // Prints false
}
exports.pageLoaded = pageLoaded;
var application = require("application");
application.mainModule = "app/template-settings/main-page";
application.start();
```
``` TypeScript
import observable = require("data/observable");
import localSettings = require("local-settings");
// Event handler for Page "loaded" event attached in main-page.xml
export function pageLoaded(args: observable.EventData) {
localSettings.setString("Name", "John Doe");
console.log(localSettings.getString("Name"));// Prints "John Doe"
localSettings.setBoolean("Married", false);
console.log(localSettings.getBoolean("Married"));// Prints false
localSettings.setNumber("Age", 42);
console.log(localSettings.getNumber("Age"));// Prints 42
console.log(localSettings.hasKey("Name"));// Prints true
localSettings.remove("Name");// Removes the Name entry.
console.log(localSettings.hasKey("Name"));// Prints false
}
import application = require("application");
application.mainModule = "app/main-page";
application.start();
```
# Using Application Callbacks
Each NativeScript application has several important lifecycle events. You can use those events to perform all kinds of needed maintanance and housekeeping:
Expand Down Expand Up @@ -107,4 +85,38 @@ application.onUncaughtError = function (error: application.NativeScriptError) {
console.log("Application error: " + error.name + "; " + error.message + "; " + error.nativeError);
}
application.start();
```
# Persist and Restore Application Settings
To persist settings that the user has defined you have to use the local-settings module. The local-settings module is a static singleton hash table that stores key-value pairs for the application. The getter methods have two parameters -- a key and an optional default value to return if the specified key does not exist. The setter methods also have two parameters -- key and value. Here is an example of using the local settings-module and all of its available methods:
``` JavaScript
var localSettings = require("local-settings");
// Event handler for Page "loaded" event attached in main-page.xml
function pageLoaded(args) {
localSettings.setString("Name", "John Doe");
console.log(localSettings.getString("Name")); // Prints "John Doe"
localSettings.setBoolean("Married", false);
console.log(localSettings.getBoolean("Married")); // Prints false
localSettings.setNumber("Age", 42);
console.log(localSettings.getNumber("Age")); // Prints 42
console.log(localSettings.hasKey("Name")); // Prints true
localSettings.remove("Name"); // Removes the Name entry.
console.log(localSettings.hasKey("Name")); // Prints false
}
exports.pageLoaded = pageLoaded;
```
``` TypeScript
import observable = require("data/observable");
import localSettings = require("local-settings");
// Event handler for Page "loaded" event attached in main-page.xml
export function pageLoaded(args: observable.EventData) {
localSettings.setString("Name", "John Doe");
console.log(localSettings.getString("Name"));// Prints "John Doe"
localSettings.setBoolean("Married", false);
console.log(localSettings.getBoolean("Married"));// Prints false
localSettings.setNumber("Age", 42);
console.log(localSettings.getNumber("Age"));// Prints 42
console.log(localSettings.hasKey("Name"));// Prints true
localSettings.remove("Name");// Removes the Name entry.
console.log(localSettings.hasKey("Name"));// Prints false
}
```
2 changes: 1 addition & 1 deletion layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
nav-title: "NativeScript Layouts"
title: "Layouts"
description: "NativeScript Documentation: Layouts"
position: 3
position: 4
---

# Layouts
Expand Down
2 changes: 1 addition & 1 deletion location.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
nav-title: "Location"
title: "Location"
description: "NativeScript Documentation: Location"
position: 8
position: 10
---

# Location
Expand Down
3 changes: 2 additions & 1 deletion navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
nav-title: "Navigation"
title: "Navigation"
description: "Navigation"
position: 0
position: 3

---
# Overview
Each NativeScript application is built upon the concept of pages (represented by the **Page** class). Pages are the different screens that your application offers. Each page has a **content** property which holds the root visual element of the page UI. Navigating between different pages is done with methods of the **Frame** class. The Frame class represents the logical unit that is responsible for navigation between different pages, i.e. going from one page to another, keeping a history stack for going back and so on.
Expand Down
2 changes: 1 addition & 1 deletion styling.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
nav-title: "NativeScript Styling"
title: "Styling"
description: "NativeScript Documentation: Styling"
position: 7
position: 5
---

# Styling
Expand Down
2 changes: 1 addition & 1 deletion ui-dialogs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
nav-title: "UI Dialogs"
title: "UI Dialogs"
description: "NativeScript Documentation: UI Dialogs"
position: 101
position: 9
---

# UI Dialogs
Expand Down
7 changes: 6 additions & 1 deletion ui-views.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#UI Views
---
nav-title: "UI Views"
title: "UI Views"
description: "UI Views"
position: 8
---

NativeScript ships with set of UI Views which can be used for building the UI of a mobile application. Most of these views wrap the corresponding native view for each platform, while providing a common API for working with them. For example the `Button` view renders an `android.widget.Button` on Android and `UIButton` on iOS.

Expand Down
2 changes: 1 addition & 1 deletion ui-with-xml.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
nav-title: "UI with XML"
title: "UI with XML"
description: "NativeScript Documentation: UI with XML"
position: 5
position: 7
---

# UI with XML
Expand Down