angular-ru-sdk
angular-ru-sdk copied to clipboard
Add worker decorator
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
I got such an idea about workers with webpack loader. We have three problems with current solution:
- 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. - We can't import into worker function any symbols, cause they will be imported to the general thread.
- 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?
import('worker-loader!./some-fn.worker.ts').then(({ someFn }) => someFn(someData))
not needed, it's work by default in angular cli
our webworker service - it's redundant for production, but only just for fun utils. We need migrate to native webpack loader from angular
Do you comment anything here? Cause i'm receiving notifications periodically, but see not updates.
@Schirbak hello, postponed, I will answer your suggestions asap