diff --git a/README.md b/README.md index b6c9e39..4fe0736 100644 --- a/README.md +++ b/README.md @@ -62,20 +62,17 @@ 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( - () => new Worker(new URL('./hello.worker', import.meta.url), { type: 'module' }), - input$, -).subscribe(message => { +fromWorker(() => new Worker('./hello.worker', { type: 'module' }), input$).subscribe(message => { console.log(message); // Outputs 'Hello from webworker' }); @@ -83,7 +80,7 @@ fromWorker( #### 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'; @@ -91,7 +88,7 @@ import { of } from 'rxjs'; const input$ = of('Hello from main thread'); fromWorker( - () => 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' diff --git a/src/readme/hello-legacy-webpack.ts b/src/readme/hello-legacy-webpack.ts new file mode 100644 index 0000000..e6c64c6 --- /dev/null +++ b/src/readme/hello-legacy-webpack.ts @@ -0,0 +1,8 @@ +import { fromWorker } from 'observable-webworker'; +import { of } from 'rxjs'; + +const input$ = of('Hello from main thread'); + +fromWorker(() => new Worker('./hello.worker', { type: 'module' }), input$).subscribe(message => { + console.log(message); // Outputs 'Hello from webworker' +}); diff --git a/src/readme/hello-webpack-5.ts b/src/readme/hello-webpack-5.ts deleted file mode 100644 index 818446a..0000000 --- a/src/readme/hello-webpack-5.ts +++ /dev/null @@ -1,12 +0,0 @@ -// @ts-nocheck - @todo remove typechecking prevention once this repo upgrades to Angular 12 stable -import { fromWorker } from 'observable-webworker'; -import { of } from 'rxjs'; - -const input$ = of('Hello from main thread'); - -fromWorker( - () => new Worker(new URL('./app.worker', import.meta.url), { type: 'module' }), - input$, -).subscribe(message => { - console.log(message); // Outputs 'Hello from webworker' -}); diff --git a/src/readme/hello.ts b/src/readme/hello.ts index 732da1a..e55cead 100644 --- a/src/readme/hello.ts +++ b/src/readme/hello.ts @@ -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';