Skip to content

Commit b949fec

Browse files
committed
style: run prettier over markdown files
1 parent 65370fc commit b949fec

12 files changed

+192
-202
lines changed

content/guide/multithreading.md

+50-50
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ For optimal results when using the Workers API, follow these guidelines:
2222
Creating a new worker is simple, all you need is to call the `Worker()` constructor with a path to the worker script (relative to current file, or an aliased path eg. `~/path/to/worker.ts`). The worker itself can be written in JavaScript or TypeScript.
2323

2424
```ts
25-
const myWorker = new Worker('./worker.ts');
25+
const myWorker = new Worker('./worker.ts')
2626
```
2727

2828
### Sending messages to a worker
@@ -31,7 +31,7 @@ To send messages to the worker, use the [`postMessage()`](#postmessage) method o
3131

3232
```ts
3333
// send myMessage to the worker
34-
myWorker.postMessage(myMessage);
34+
myWorker.postMessage(myMessage)
3535
```
3636

3737
### Receiving messages from a worker
@@ -41,9 +41,9 @@ To receive messages from the worker, use the [`onmessage`](#onmessage) callback
4141
```ts
4242
// attach a message handler that will receive messages from the worker thread
4343
myWorker.onmessage = (e) => {
44-
console.log('Message received from the worker thread.');
45-
const data = e.data; // data from the worker
46-
};
44+
console.log('Message received from the worker thread.')
45+
const data = e.data // data from the worker
46+
}
4747
```
4848

4949
### Sending messages to main thread
@@ -52,7 +52,7 @@ To send messages back to the main thread use the [`self.postMessage()`](#postmes
5252

5353
```ts
5454
// send the workerResult back to the main thread
55-
self.postMessage(workerResult);
55+
self.postMessage(workerResult)
5656
```
5757

5858
### Receiving messages from main thread
@@ -62,9 +62,9 @@ To receive messages in the worker, use the [`self.onmessage`](#onmessage-1) even
6262
```ts
6363
// attach a message handler that will receive the messages from the main thread
6464
self.onmessage = (e) => {
65-
console.log('Message received from the main thread.');
66-
const data = e.data; // data from myMessage
67-
};
65+
console.log('Message received from the main thread.')
66+
const data = e.data // data from myMessage
67+
}
6868
```
6969

7070
<!-- ### Sending messages to and from a worker
@@ -102,7 +102,7 @@ self.onmessage = (e) => {
102102
If you need to stop executing the worker, you can terminate it from the main thread using the `terminate` method on the `Worker` instance:
103103

104104
```ts
105-
myWorker.terminate();
105+
myWorker.terminate()
106106
```
107107

108108
The worker thread is killed immediately.
@@ -115,20 +115,20 @@ Runtime errors inside the worker are reported back to the main thread through th
115115
myWorker.onerror = (e) => {
116116
console.log(
117117
`Error occured in the worker thread in file ${e.filename} on line ${e.lineno}`
118-
);
119-
console.log(e.message, e.stackTrace);
120-
};
118+
)
119+
console.log(e.message, e.stackTrace)
120+
}
121121
```
122122

123123
The worker can also self-handle errors by setting up an `onerror` handler, which can mark the error as "handled" and prevent the callback on the main thread from being called.
124124

125125
```ts
126126
self.onerror = (e) => {
127-
console.log('Error occured, error:', e);
127+
console.log('Error occured, error:', e)
128128

129129
// return true-like to stop the event from being passed onto the main thread
130-
return true;
131-
};
130+
return true
131+
}
132132
```
133133

134134
## Workers API
@@ -146,7 +146,7 @@ Creates an instance of a Worker and spawns a new OS thread, where the script poi
146146
### postMessage
147147

148148
```ts
149-
myWorker.postMessage(message);
149+
myWorker.postMessage(message)
150150
```
151151

152152
Sends a JSON-serializable message to the associated script's `onmessage` event handler.
@@ -156,7 +156,7 @@ Sends a JSON-serializable message to the associated script's `onmessage` event h
156156
### terminate
157157

158158
```ts
159-
myWorker.terminate();
159+
myWorker.terminate()
160160
```
161161

162162
Terminates the execution of the worker thread on the next run loop tick.
@@ -166,7 +166,7 @@ Terminates the execution of the worker thread on the next run loop tick.
166166
### onmessage
167167

168168
```ts
169-
myWorker.onmessage = function handler(message: { data: any }) {};
169+
myWorker.onmessage = function handler(message: { data: any }) {}
170170
```
171171

172172
Handles incoming messages sent from the associated worker thread. **Note** that you are responsible for creating & setting the handler function.
@@ -179,11 +179,11 @@ The `data` in the `message` object is the JSON-serializable message the worker s
179179

180180
```ts
181181
myWorker.onerror = function handler(error: {
182-
message: string; // the error message
183-
stackTrace?: string; // the stack trace if applicable
184-
filename: string; // the file where the uncaught error was thrown
185-
lineno: number; // the line where the uncaught error was thrown
186-
}) {};
182+
message: string // the error message
183+
stackTrace?: string // the stack trace if applicable
184+
filename: string // the file where the uncaught error was thrown
185+
lineno: number // the line where the uncaught error was thrown
186+
}) {}
187187
```
188188

189189
Handles uncaught errors from the worker thread. **Note** that you are responsible for creating & setting the handler function.
@@ -197,7 +197,7 @@ Each worker gets it's own global scope (so `global.foo` in the worker is not the
197197
### self
198198

199199
```ts
200-
self === global; // true
200+
self === global // true
201201
```
202202

203203
Returns a reference to the `WorkerGlobalScope` itself - also available as `global`
@@ -207,7 +207,7 @@ Returns a reference to the `WorkerGlobalScope` itself - also available as `globa
207207
### postMessage
208208

209209
```ts
210-
self.postMessage(message);
210+
self.postMessage(message)
211211
```
212212

213213
Sends a JSON-serializable message to the Worker instance's [`onmessage`](#onmessage) event handler on the main thread.
@@ -217,7 +217,7 @@ Sends a JSON-serializable message to the Worker instance's [`onmessage`](#onmess
217217
### close
218218

219219
```ts
220-
self.close();
220+
self.close()
221221
```
222222

223223
Terminates the execution of the worker thread on the next run loop tick.
@@ -227,7 +227,7 @@ Terminates the execution of the worker thread on the next run loop tick.
227227
### onmessage
228228

229229
```ts
230-
self.onmessage = function handler(message: { data: any }) {};
230+
self.onmessage = function handler(message: { data: any }) {}
231231
```
232232

233233
Handles incoming messages sent from the main thread.
@@ -240,8 +240,8 @@ The `data` in the `message` object is the JSON-serializable message the main thr
240240

241241
```ts
242242
self.onerror = function handler(error: Error): boolean {
243-
return true;
244-
};
243+
return true
244+
}
245245
```
246246

247247
Handles uncaught errors occurring during execution of functions inside the Worker Scope (worker thread).
@@ -257,7 +257,7 @@ After `onerror` is called in the worker thread, execution is not terminated and
257257
```ts
258258
self.onclose = function handler() {
259259
// do cleanup work
260-
};
260+
}
261261
```
262262

263263
Handles any "clean-up" work. Suitable for freeing up resources, closing streams and sockets.
@@ -270,7 +270,7 @@ Handles any "clean-up" work. Suitable for freeing up resources, closing streams
270270
In order to use `setTimeout`, `setInterval`, or other globals coming from the `@nativescript/core`, you will need to include them in your worker script:
271271

272272
```ts
273-
import '@nativescript/core/globals';
273+
import '@nativescript/core/globals'
274274
```
275275

276276
<!-- -->
@@ -280,31 +280,31 @@ import '@nativescript/core/globals';
280280
```ts
281281
// main-view-model.js
282282

283-
const worker = new Worker('./workers/image-processor');
283+
const worker = new Worker('./workers/image-processor')
284284

285285
// send a message to our worker
286-
worker.postMessage({ src: imageSource, mode: 'scale', options: options });
286+
worker.postMessage({ src: imageSource, mode: 'scale', options: options })
287287

288288
// handle incoming messages from the worker
289289
worker.onmessage = function (message) {
290290
if (message.data.success) {
291291
// the src received from the worker
292-
const src = message.data.src;
292+
const src = message.data.src
293293

294294
// terminate worker or send another message...
295-
worker.terminate();
295+
worker.terminate()
296296
} else {
297297
// handle unsuccessful task
298298
}
299-
};
299+
}
300300

301301
// handle worker errors
302302
worker.onerror = function (err) {
303303
console.log(
304304
`An unhandled error occurred in worker: ${err.filename}, line: ${err.lineno} :`,
305305
err.message
306-
);
307-
};
306+
)
307+
}
308308
```
309309

310310
<!-- -->
@@ -313,36 +313,36 @@ worker.onerror = function (err) {
313313
// workers/image-processor.js
314314

315315
// load NativeScript globals in the worker thread
316-
import '@nativescript/core/globals';
316+
import '@nativescript/core/globals'
317317

318318
self.onmessage = function (message) {
319-
const src = message.data.src;
320-
const mode = message.data.mode || 'noop';
321-
const options = message.data.options;
319+
const src = message.data.src
320+
const mode = message.data.mode || 'noop'
321+
const options = message.data.options
322322

323-
const result = processImage(src, mode, options);
323+
const result = processImage(src, mode, options)
324324

325325
if (result) {
326326
// send the result back to the main thread
327327
self.postMessage({
328328
success: true,
329329
src: result,
330-
});
330+
})
331331

332-
return;
332+
return
333333
}
334334

335335
// no result, send back an empty object for example
336-
self.postMessage({});
337-
};
336+
self.postMessage({})
337+
}
338338

339339
// example heavy function to process an image
340340
function processImage(src, mode, options) {
341-
console.log(options);
341+
console.log(options)
342342
// image processing logic
343343
// save image, retrieve location
344344
// return source to processed image
345-
return updatedImgSrc;
345+
return updatedImgSrc
346346
}
347347
```
348348

content/parts/troubleshooting-increase-deployment-target.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ end
2020

2121
In this example we are setting it to `13.0` - change it to a version that makes sense for your project. Some libraries will require higher targets, so in most cases find the highest required target, and use that as your deployment target. Make sure to match both `build.xcconfig` and `Podfile` versions.
2222

23-
In case this doesn't resolve the issue, you can often [delete the XCode DerivedData](#deleting-xcode-deriveddata).
23+
In case this doesn't resolve the issue, you can often [delete the XCode DerivedData](#deleting-xcode-deriveddata).

content/project-structure/app-resources.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ class HelloJava {
7575
Given the example above, your JavaScript or TypeScript code can reference the Kotlin or Java code by using the full class names, e.g.
7676

7777
```typescript
78-
const helloKotlin = new com.example.HelloKotlin();
79-
console.log('Kotlin says: ' + helloKotlin.hello);
78+
const helloKotlin = new com.example.HelloKotlin()
79+
console.log('Kotlin says: ' + helloKotlin.hello)
8080
// prints: Kotlin says: Hello from Kotlin!
8181

82-
const helloJava = new com.example.HelloJava();
83-
console.log('Java says: ' + helloJava.getString());
82+
const helloJava = new com.example.HelloJava()
83+
console.log('Java says: ' + helloJava.getString())
8484
// prints: Java says: Hello from Java!
8585
```
8686

@@ -89,7 +89,7 @@ console.log('Java says: ' + helloJava.getString());
8989
If using TypeScript, you may need to generate typings, or alternatively declare the top level package name as `any`, e.g.
9090

9191
```typescript
92-
declare const com: any;
92+
declare const com: any
9393
```
9494
9595
:::

0 commit comments

Comments
 (0)