angular-ru-sdk icon indicating copy to clipboard operation
angular-ru-sdk copied to clipboard

Add worker decorator

Open splincode opened this issue 2 years ago • 5 comments

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/ngxs/store/blob/master/CONTRIBUTING.md#commit
  • [ ] Tests for the changes have been added (for bug fixes / features)
  • [ ] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[ ] No

splincode avatar Dec 09 '21 08:12 splincode

@splincode

I got such an idea about workers with webpack loader. We have three problems with current solution:

  1. We can pass into WorkerService inline function which is using lexical environment. So since the function will be converted to string, it won't work.
  2. We can't import into worker function any symbols, cause they will be imported to the general thread.
  3. We can't point to the vars from the general thread. We can only serialize and post them as string.

So i suggest to make a webworker webpack loader. It will force user to separate the side function at least outside the lexical environment (namely, to the separate file) — 1.

import('worker-loader!./some-fn.worker.ts').then(({ someFn }) => someFn(someData))

As we move the code to separate file, webpack can correctly import any symbols to it — 2. The third problem can be solved with SharedArrayBuffer, but I'm not sure.

Wyt? Isn't it an overhead?

Markiewic avatar Dec 10 '21 12:12 Markiewic

image

import('worker-loader!./some-fn.worker.ts').then(({ someFn }) => someFn(someData))

not needed, it's work by default in angular cli

splincode avatar Dec 10 '21 12:12 splincode

our webworker service - it's redundant for production, but only just for fun utils. We need migrate to native webpack loader from angular

splincode avatar Dec 10 '21 12:12 splincode

Do you comment anything here? Cause i'm receiving notifications periodically, but see not updates.

Markiewic avatar Dec 23 '21 20:12 Markiewic

@Schirbak hello, postponed, I will answer your suggestions asap

splincode avatar Dec 23 '21 21:12 splincode