Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
wellcaffeinated committed May 24, 2019
1 parent d0f1e7b commit 2ef52b5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ In the example below, the sole difference between running `MyClass` on a Worker
import rnd from 'random-int';

// Export as you would in a normal module:
export const function meaningOfLife(){
return 42;
}

export class MyClass {
constructor(value = rnd()) {
this.value = value;
Expand All @@ -50,13 +54,16 @@ export class MyClass {
**main.js**: _(our demo, on the main thread)_

```js
import { MyClass } from 'comlink-loader!./my-class';
import worker from 'comlink-loader!./my-class';
const inst = worker();

await inst.meaningOfLife(); // 42

const inst = await new MyClass(42); // notice the await
const obj = await new inst.MyClass(42); // notice the await

await inst.increment();
await obj.increment();

await inst.getValue(); // 43
await obj.getValue(); // 43
```

## License
Expand Down

0 comments on commit 2ef52b5

Please sign in to comment.