Skip to content

Commit d7aa225

Browse files
Doc++
1 parent b247c15 commit d7aa225

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
A live-update service for your NativeScript apps!
1717

1818
<details>
19-
<summary>What this is, and how it works (optional reading).</summary>
19+
<summary>*Optional reading: what this is, and how it works*</summary>
2020

2121
A NativeScript app is composed of XML/HTML, CSS and JavaScript files and any accompanying images, which are bundled together by the NativeScript CLI and distributed as part of a platform-specific binary (i.e. an .ipa or .apk file). Once the app is released, updating either the code (e.g. making bug fixes, adding new features) or image assets, requires you to recompile and redistribute the entire binary, which of course, includes any review time associated with the store(s) you are publishing to.
2222

@@ -130,7 +130,7 @@ warm restart (`InstallMode.ON_NEXT_RESUME`), or a positive response to a user pr
130130

131131
Note that Apple doesn't want you to prompt the user to restart your app, so use `InstallMode.IMMEDIATE` on iOS only for Enterprise-distributed apps (or when testing your app through TestFlight for instance).
132132

133-
> Check out the [demo](/demo) for a solid example.
133+
> 💁‍♂️ Check out the [demo](/demo) for a solid example.
134134
135135
```typescript
136136
// import the main plugin classes
@@ -202,18 +202,33 @@ CodePush.sync({
202202

203203
</details>
204204

205+
#### When should this check run?
205206
It's recommended to check for updates more than once in a cold boot cycle,
206-
so it may be easiest to tie this check to the `resume` event:
207+
so it may be easiest to tie this check to the `resume` event (which usually also runs on app startup):
207208

208209
```typescript
209210
import * as application from "tns-core-modules/application";
211+
import { CodePush } from "nativescript-code-push";
210212

211213
// add this in some central place that's executed once in a lifecycle
212214
application.on(application.resumeEvent, () => {
213215
CodePush.sync(...);
214216
});
215217
```
216218

219+
<details>
220+
<summary>Click here to see a JavaScript example</summary>
221+
222+
```js
223+
var application = require("tns-core-modules/application");
224+
225+
application.on(application.resumeEvent, function () {
226+
// call the sync function
227+
});
228+
```
229+
230+
</details>
231+
217232
## Releasing an update
218233
Once your app has been configured and distributed to your users, and you've made some code and/or asset changes,
219234
it's time to instantly unleash those changes onto your users!

demo/demoapp/main-view-model.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export class HelloWorldModel extends Observable {
2020
this.codePush = new CodePush();
2121

2222
// Check for updates when the app is loaded or resumed
23-
application.on(application.resumeEvent, () => this.syncWithCodePushServer());
23+
application.on(application.resumeEvent, () => {
24+
this.syncWithCodePushServer();
25+
});
2426
}
2527

2628
private syncWithCodePushServer(): void {

0 commit comments

Comments
 (0)