Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.
16 changes: 9 additions & 7 deletions core-concepts/accessing-native-apis-with-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,16 @@ Steps to install and enable
- Modify `tsconfig.json` to contain the following settings:
```
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"lib": [
"es2016"
"compilerOptions": {
...
"lib": ["es6", "dom"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have comma at the end of the row

"baseUrl": ".",
"paths": {
"*": [
"./node_modules/tns-core-modules/*",
"./node_modules/*"
]
}
}
}
```
Note that d.ts files require a lot of memory and CPU. Consider adding skipLibCheck option to `tsconfig.json`.
Expand Down
14 changes: 7 additions & 7 deletions core-concepts/application-lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Components are the fundamental building blocks of NativeScript applications buil
### Component example

``` TypeScript
import {Component} from "@angular/core";
import { Component } from "@angular/core";

@Component({
selector: "main-component",
Expand Down Expand Up @@ -148,7 +148,7 @@ application.start({ moduleName: "main-page" });
iOS calls UIApplication and triggers the application main event loop.
*/

import application = require("application");
import * as application from "application";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we import only the used methods from application?

import { on, uncaughtErrorEvent } from "application";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed but I think it is better to leave this specific example to import application as it is more readable application.on instead of just on

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use:
import { on as applicationOn }

the application module exports 46 things and we don't need most of them. If we import the whole module we can't benefit from the treeshaking that uglify.js performs.

application.start({ moduleName: "main-page" });
```
{% endnativescript %}
Expand Down Expand Up @@ -234,7 +234,7 @@ application.start({ moduleName: "main-page" });
```
{% endnativescript %}
``` TypeScript
import application = require("application");
import * as application from "application";
application.on(application.launchEvent, function (args: application.ApplicationEventData) {
if (args.android) {
// For Android applications, args.android is an android.content.Intent class.
Expand Down Expand Up @@ -360,7 +360,7 @@ application.start();
```
{% endnativescript %}
``` TypeScript
import application = require("application");
import * as application from "application";

// Android activity events
if (application.android) {
Expand Down Expand Up @@ -435,7 +435,7 @@ application.start();
```
{% endnativescript %}
``` TypeScript
import application = require("application");
import * as application from "application";
class MyDelegate extends UIResponder implements UIApplicationDelegate {
public static ObjCProtocols = [UIApplicationDelegate];

Expand Down Expand Up @@ -481,8 +481,8 @@ exports.pageLoaded = pageLoaded;
```
{% endnativescript %}
``` TypeScript
import observable = require("data/observable");
import applicationSettings = require("application-settings");
import * as observable from "data/observable";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import { EventData } from "data/observable";

import * as applicationSettings from "application-settings";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

// Event handler for Page "loaded" event attached in main-page.xml.
export function pageLoaded(args: observable.EventData) {
applicationSettings.setString("Name", "John Doe");
Expand Down
Loading