Skip to content

Feat: Run angular in web worker mode #2305

Closed

Description

@k3nsei

In current setup there is no possibility to bootstrap angular in web worker mode.
Please add this killer functionality.

Activity

  1. added
    P5The team acknowledges the request but does not plan to address it, it remains open for discussion
    on Oct 3, 2016
  2. datrinh commented on Oct 9, 2016

    @datrinh

    Currently also looking for a good way to accomplish it. Any1 got a workaround for now?

  3. filipesilva commented on Oct 10, 2016

    @filipesilva
    Contributor

    No support at the moment, but we are looking at it.

  4. armaserg commented on Dec 29, 2016

    @armaserg

    Any news here?
    Thanks!

  5. alexjlockwood commented on Feb 20, 2017

    @alexjlockwood

    I'm also curious if there have been any updates to this.

  6. jhertz123 commented on Mar 28, 2017

    @jhertz123

    Also looking for this.

  7. IPRIT commented on Apr 9, 2017

    @IPRIT

    ... need this feature!!!

  8. maxime1992 commented on Apr 15, 2017

    @maxime1992
    Contributor

    For those who can't wait, I've found a good post on stackoverflow.

    I've heard of Angular running in a webworker in the early days of angular.
    But when you try it out on a real demo : https://kaikcreator.github.io/angular-cli-web-worker/ ...
    It's something 🎉 !

    Now I'm just wondering whether I'm gonna wait for built in solution with the cli or ng eject 😄

  9. bmayen commented on Apr 19, 2017

    @bmayen

    The stackoverflow approach seems reasonable. Would a PR with this be welcome here?

  10. maxime1992 commented on Apr 19, 2017

    @maxime1992
    Contributor

    Gotta try to find out @bmayen ! Seriously I think that yes it'd be welcome and even tho it might not be perfect the first time after few iterations it might go to master ... 😃

    Don't forget to reference this issue if you try something so we can follow what's going on 👍 !

  11. jakeNiemiec commented on Apr 19, 2017

    @jakeNiemiec

    @maxime1992 Thanks for posting that, I'm not sure why workers (--mobile) were cut from angular-cli.

  12. changed the title [-]Feat: Run angular2 in web worker mode[/-] [+]Feat: Run angular in web worker mode[/+] on Apr 21, 2017
  13. self-assigned this
    on May 4, 2017
  14. 54 remaining items

  15. LeonBarroso commented on Mar 13, 2019

    @LeonBarroso

    @glemiere it gives me webworker.bundle.js not found
    where I can find webworker.bundle.js ?
    Thanks

  16. cedvdb commented on Mar 19, 2019

    @cedvdb

    @glemiere good work.

    Is angular official support for this ever gonna be a thing ?

  17. bmayen commented on May 24, 2019

    @bmayen

    platform-webworker deprecated
    angular/angular#30642

  18. glemiere commented on Jun 10, 2019

    @glemiere

    Indeed @bmayen it's not officially deprecated in v8 angular/angular@361f181

    That is a huge disappointment. We were all very excited about this.
    To let everybody know, it is still possible to run parts of your code inside a webworker to make multi-threading possible. I just wish Angular had at least offered the possibility to run services or anything web crawlers don't care much about in separate threads.

    I will be digging into making a library to make this behavior possible and developer friendly, any help is welcome. Thanks everybody for the hard work💪

  19. filipesilva commented on Jun 10, 2019

    @filipesilva
    Contributor

    Running Angular itself in a Web Worker (via @angular/platform-webworker) is indeed deprecated. But it is now easier to run parts of your app in a Web Worker using https://angular.io/guide/web-worker.

  20. dherges commented on Mar 6, 2020

    @dherges

    I came across web workers recently and early thoughts went into the direction of @angular/platform-browser:

    • abstract the DOM APIs away,
    • thus, code would run in a worker...

    I just flipped the idea the other way around:

    • DONT ABSTRACT the DOM APIs away,
    • Extract the supposed to run in a worker-code,
    • Wrap it in a if no worker-fallback.

    You would end up with a style of code like this:

    // All worker-compatible code goes to @my/worker
    import { WorkerFacade, workerCompatibleCode } from '@my/worker';
    
    // WorkerFacade would implement the "if no worker" fallback and messaging from UI to worker
    const myWorker: WorkerFacade = /* ... */
    
    const runnableInWorker = myWorker
      // You would need to map messages to function calls in the worker (not shown here)
      .postToWorker({ run: 'workerCompatibleCode', data: { foo: 'bar' } })
      // workerCompatibleCode() would be run in the UI were web worker isn't available
      .orElse(() => workerCompatibleCode());
    
    runnableInWorker.subscribe(result=> {
     console.log("result was returned either from a web worker or from UI process");
    });
  21. dgp1130 commented on Jun 24, 2020

    @dgp1130
    Collaborator

    Running Angular inside a web worker has been deprecated for a while now, as it just isn't typically beneficial for performance: https://angular.io/guide/deprecations#webworker-apps. As a result, the CLI doesn't support this use case anymore.

    Applications can still add web workers to run their own CPU-intensive tasks, just not running Angular itself. See https://angular.io/guide/web-worker for more on that.

  22. pshields commented on Jun 24, 2020

    @pshields

    I'd really like to use angular's dependency injection system in my web workers. I have a bunch of heavily modularized Angular services that rely heavily on the Angular DI system. I'd like to use some of those services in a web worker (even if it meant instantiating a secondary service tree that lived on the web worker side.) Does anyone have any suggestions on how to replicate that kind of approach in a web worker? Ideally reusing the actual service code, if possible?

  23. maxime1992 commented on Jun 25, 2020

    @maxime1992
    Contributor

    @pshields I assume using Angular DI system directly into a webworker would be hard but I remember that Minko extracted the DI part into a separate project which is browser agnostic (can work on Node) 🎉

    https://github.com/mgechev/injection-js Maybe this will help you

  24. removed
    needs: discussionOn the agenda for team meeting to determine next steps
    on Jun 26, 2020
  25. angular-automatic-lock-bot commented on Jul 27, 2020

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  26. locked and limited conversation to collaborators on Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions