From 11b7c1dd5ed3e19e9e29a2bc79e270e3ce0b4d7c Mon Sep 17 00:00:00 2001 From: Zak Henry Date: Tue, 15 Feb 2022 09:38:38 +1300 Subject: [PATCH] fix(Readme): Update readme to better reflect that the old style of worker construction is deprecated --- README.md | 13 +++++-------- src/readme/hello-legacy-webpack.ts | 8 ++++++++ src/readme/hello-webpack-5.ts | 12 ------------ src/readme/hello.ts | 1 + 4 files changed, 14 insertions(+), 20 deletions(-) create mode 100644 src/readme/hello-legacy-webpack.ts delete mode 100644 src/readme/hello-webpack-5.ts 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';