Skip to content
This repository has been archived by the owner on Sep 9, 2021. It is now read-only.

change worker file path inline #102

Closed
bautistaaa opened this issue Oct 20, 2017 · 4 comments
Closed

change worker file path inline #102

bautistaaa opened this issue Oct 20, 2017 · 4 comments

Comments

@bautistaaa
Copy link

bautistaaa commented Oct 20, 2017

Hey guys,

Is there anyways to override the path inline? Or how I can fix it in the webpack config. Tried all the examples i the documentation with no luck.

I am using this angular 2 seed here. https://github.com/UIUXEngineering/web-worker-in-ng

We have to transpile the worker before angular so we use a separate webpack config https://github.com/UIUXEngineering/web-worker-in-ng/blob/master/webpack.worker.config.js

This is how we load the workers
`
import { Injectable } from '@angular/core';
import * as DemoOneWorker from 'worker-loader!../../web-workers/worker-demo1/demo1.worker.bundle.js';
import * as DemoTwoWorker from 'worker-loader!../../web-workers/worker-demo2/demo2.worker.bundle.js';

@Injectable()
export class WebWorkerService {

demoOneWorker: Worker = new DemoOneWorker();
demoTwoWorker: Worker = new DemoTwoWorker();

constructor() {
}

initialize() {

// Demo 1 worker
this.demoOneWorker.onmessage = function ( event ) {
  const data = event.data; // "This text was generated by template B"
  console.log('Web Worker ONE Response: ', data);
};

const that = this;

setTimeout(function () {
  console.log('\n\nPosting message to web worker ONE');
  that.demoOneWorker.postMessage('Worker ONE Data');
}, 1000);

// Demo 2 worker
this.demoTwoWorker.onmessage = function ( event ) {
  const data = event.data; // "This text was generated by template B"
  console.log('Web Worker TWO Response: ', data);
};

setTimeout(function () {
  console.log('\n\nPosting message to web worker TWO');
  that.demoTwoWorker.postMessage('Worker TWO Data');
}, 2000);

}

}`
Not sure how to go about fixing this.

@bautistaaa
Copy link
Author

eh I just forked it and overrode the public path in index js o.O

@michael-ciniawsky
Copy link
Member

There is #31 on master but unfortunately not released yet. Why not opening a PR in case you have different need and it's a 'common' usecase instead of just forking the repo :) ?

@bautistaaa
Copy link
Author

let me find a better reusable way! I literally just hardcoded a path haha

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Oct 21, 2017

Can you share the link to your repo or the changed line at best, so I can check what you're after 🙃 ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants