Skip to content

Commit

Permalink
fix(Readme): Update readme to better reflect that the old style of wo…
Browse files Browse the repository at this point in the history
…rker construction is deprecated
  • Loading branch information
zak-cloudnc committed Feb 14, 2022
1 parent 49e16aa commit 11b7c1d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,36 +62,33 @@ yarn add observable-webworker

💡 Take note! The webworker construction syntax differs for different version of webpack:

#### Webpack < 5
#### Webpack < 5 (deprecated)

```ts
// src/readme/hello.ts
// src/readme/hello-legacy-webpack.ts

import { fromWorker } from 'observable-webworker';
import { of } from 'rxjs';

const input$ = of('Hello from main thread');

fromWorker<string, string>(
() => new Worker(new URL('./hello.worker', import.meta.url), { type: 'module' }),
input$,
).subscribe(message => {
fromWorker<string, string>(() => new Worker('./hello.worker', { type: 'module' }), input$).subscribe(message => {
console.log(message); // Outputs 'Hello from webworker'
});

```
#### Webpack 5

```ts
// src/readme/hello-webpack-5.ts#L2-L12
// src/readme/hello.ts#L2-L12

import { fromWorker } from 'observable-webworker';
import { of } from 'rxjs';

const input$ = of('Hello from main thread');

fromWorker<string, string>(
() => new Worker(new URL('./app.worker', import.meta.url), { type: 'module' }),
() => new Worker(new URL('./hello.worker', import.meta.url), { type: 'module' }),
input$,
).subscribe(message => {
console.log(message); // Outputs 'Hello from webworker'
Expand Down
8 changes: 8 additions & 0 deletions src/readme/hello-legacy-webpack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { fromWorker } from 'observable-webworker';
import { of } from 'rxjs';

const input$ = of('Hello from main thread');

fromWorker<string, string>(() => new Worker('./hello.worker', { type: 'module' }), input$).subscribe(message => {
console.log(message); // Outputs 'Hello from webworker'
});
12 changes: 0 additions & 12 deletions src/readme/hello-webpack-5.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/readme/hello.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck - @todo remove typechecking prevention once the typescript config supports it
import { fromWorker } from 'observable-webworker';
import { of } from 'rxjs';

Expand Down

0 comments on commit 11b7c1d

Please sign in to comment.