How does web worker call methods defined in Typescript class?Evaluate Typescript from string?How to change an element's class with JavaScript?How to manage a redirect request after a jQuery Ajax callHow do I add a class to a given element?How does JavaScript .prototype work?How to check a not-defined variable in JavaScriptHow can I select an element with multiple classes in jQuery?How does the “this” keyword work?How does data binding work in AngularJS?How do I return the response from an asynchronous call?How does Facebook disable the browser's integrated Developer Tools?

If a non-friend comes across my Steam Wishlist, how easily can he gift me one of the games?

How can a dictatorship government be beneficial to a dictator in a post-scarcity society?

How to tell someone I'd like to become friends without letting them think I'm romantically interested in them?

How can I get a player to accept that they should stop trying to pull stunts without thinking them through first?

Why does this quadratic expression have three zeroes?

Is the genetic term "polycistronic" still used in modern biology?

Can a Beast Master ranger have its beast chase down and attack enemies?

C program to parse source code of another language

What is a solution?

Modulus Operandi

How would my creatures handle groups without a strong concept of numbers?

Are there any sports for which the world's best player is female?

As the Dungeon Master, how do I handle a player that insists on a specific class when I already know that choice will cause issues?

Print the last, middle and first character of your code

Graduate student with abysmal English writing skills, how to help

Why were Er and Onan punished if they were under 20?

Is anyone advocating the promotion of homosexuality in UK schools?

Why didn't Thanos kill all the Dwarves on Nidavellir?

Cops: The Hidden OEIS Substring

Confirming the Identity of a (Friendly) Reviewer After the Reviews

Does throwing a penny at a train stop the train?

Why is a Gelman-Rubin diagnostic of < 1.1 considered acceptable?

When casting Eldritch Blast with the Agonizing Blast eldritch invocation, what do I add to my damage roll?

Changing trains in the Netherlands



How does web worker call methods defined in Typescript class?


Evaluate Typescript from string?How to change an element's class with JavaScript?How to manage a redirect request after a jQuery Ajax callHow do I add a class to a given element?How does JavaScript .prototype work?How to check a not-defined variable in JavaScriptHow can I select an element with multiple classes in jQuery?How does the “this” keyword work?How does data binding work in AngularJS?How do I return the response from an asynchronous call?How does Facebook disable the browser's integrated Developer Tools?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am trying to move heavy calculation task or method-calls to separate web workers. I am using URL.createObjectURL(blob) to inject worker code. But from the code, it has to call some other functions which are defined in Typescript (it is hard to put all complex logic in the worker's blob).



let workers = ;

export function mapWorker<T, R>(cb: (value: T) => R, input: any): Observable<R>

const subject = new Subject<R>();
let workerString = cb.toString();
let worker: Worker;

if (workers[workerString])

worker = workers[workerString];
else
worker = createStaticWorker(cb);
workers[workerString] = worker;


worker.onmessage = e => subject.next(e.data);
worker.onerror = err => subject.error(err);
worker.postMessage(input);
return subject;


export function createStaticWorker(fn: Function): Worker

const blob = new Blob(
[ 'self.cb = ', fn.toString(), ';',
'self.onmessage = function (e) self.postMessage(self.cb(e.data)) '
],
type: 'text/javascript'

);
const url = URL.createObjectURL(blob);
return new Worker(url);



When using it, I did this.



 mapWorker(x =>

return Helper.AsyncCalc(x as Array<any>);
, inputs).subscribe(value => this.areas = value);


Then 'Helper.AsyncCalc' was the method defined in Helper.ts which contains majority of the logic. I noted that in run time the 'helper' name has been
compiled to different name in JS which led to an error saying that was undefined. Could someone help on this? Is there any way to call Typescript method from that js inline method?



Thanks so much in advance.










share|improve this question






















  • I am really not into TypeScript nor Angular, but your question basically asks how to eval TypeScript source at run time, just like this question did before. So I won't use mjolnir here, but if you think your question indeed is the same as this one, let me know, so I can link them together.

    – Kaiido
    Mar 26 at 3:11

















0















I am trying to move heavy calculation task or method-calls to separate web workers. I am using URL.createObjectURL(blob) to inject worker code. But from the code, it has to call some other functions which are defined in Typescript (it is hard to put all complex logic in the worker's blob).



let workers = ;

export function mapWorker<T, R>(cb: (value: T) => R, input: any): Observable<R>

const subject = new Subject<R>();
let workerString = cb.toString();
let worker: Worker;

if (workers[workerString])

worker = workers[workerString];
else
worker = createStaticWorker(cb);
workers[workerString] = worker;


worker.onmessage = e => subject.next(e.data);
worker.onerror = err => subject.error(err);
worker.postMessage(input);
return subject;


export function createStaticWorker(fn: Function): Worker

const blob = new Blob(
[ 'self.cb = ', fn.toString(), ';',
'self.onmessage = function (e) self.postMessage(self.cb(e.data)) '
],
type: 'text/javascript'

);
const url = URL.createObjectURL(blob);
return new Worker(url);



When using it, I did this.



 mapWorker(x =>

return Helper.AsyncCalc(x as Array<any>);
, inputs).subscribe(value => this.areas = value);


Then 'Helper.AsyncCalc' was the method defined in Helper.ts which contains majority of the logic. I noted that in run time the 'helper' name has been
compiled to different name in JS which led to an error saying that was undefined. Could someone help on this? Is there any way to call Typescript method from that js inline method?



Thanks so much in advance.










share|improve this question






















  • I am really not into TypeScript nor Angular, but your question basically asks how to eval TypeScript source at run time, just like this question did before. So I won't use mjolnir here, but if you think your question indeed is the same as this one, let me know, so I can link them together.

    – Kaiido
    Mar 26 at 3:11













0












0








0








I am trying to move heavy calculation task or method-calls to separate web workers. I am using URL.createObjectURL(blob) to inject worker code. But from the code, it has to call some other functions which are defined in Typescript (it is hard to put all complex logic in the worker's blob).



let workers = ;

export function mapWorker<T, R>(cb: (value: T) => R, input: any): Observable<R>

const subject = new Subject<R>();
let workerString = cb.toString();
let worker: Worker;

if (workers[workerString])

worker = workers[workerString];
else
worker = createStaticWorker(cb);
workers[workerString] = worker;


worker.onmessage = e => subject.next(e.data);
worker.onerror = err => subject.error(err);
worker.postMessage(input);
return subject;


export function createStaticWorker(fn: Function): Worker

const blob = new Blob(
[ 'self.cb = ', fn.toString(), ';',
'self.onmessage = function (e) self.postMessage(self.cb(e.data)) '
],
type: 'text/javascript'

);
const url = URL.createObjectURL(blob);
return new Worker(url);



When using it, I did this.



 mapWorker(x =>

return Helper.AsyncCalc(x as Array<any>);
, inputs).subscribe(value => this.areas = value);


Then 'Helper.AsyncCalc' was the method defined in Helper.ts which contains majority of the logic. I noted that in run time the 'helper' name has been
compiled to different name in JS which led to an error saying that was undefined. Could someone help on this? Is there any way to call Typescript method from that js inline method?



Thanks so much in advance.










share|improve this question














I am trying to move heavy calculation task or method-calls to separate web workers. I am using URL.createObjectURL(blob) to inject worker code. But from the code, it has to call some other functions which are defined in Typescript (it is hard to put all complex logic in the worker's blob).



let workers = ;

export function mapWorker<T, R>(cb: (value: T) => R, input: any): Observable<R>

const subject = new Subject<R>();
let workerString = cb.toString();
let worker: Worker;

if (workers[workerString])

worker = workers[workerString];
else
worker = createStaticWorker(cb);
workers[workerString] = worker;


worker.onmessage = e => subject.next(e.data);
worker.onerror = err => subject.error(err);
worker.postMessage(input);
return subject;


export function createStaticWorker(fn: Function): Worker

const blob = new Blob(
[ 'self.cb = ', fn.toString(), ';',
'self.onmessage = function (e) self.postMessage(self.cb(e.data)) '
],
type: 'text/javascript'

);
const url = URL.createObjectURL(blob);
return new Worker(url);



When using it, I did this.



 mapWorker(x =>

return Helper.AsyncCalc(x as Array<any>);
, inputs).subscribe(value => this.areas = value);


Then 'Helper.AsyncCalc' was the method defined in Helper.ts which contains majority of the logic. I noted that in run time the 'helper' name has been
compiled to different name in JS which led to an error saying that was undefined. Could someone help on this? Is there any way to call Typescript method from that js inline method?



Thanks so much in advance.







javascript angular typescript web






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 26 at 2:26









RichRich

429 bronze badges




429 bronze badges












  • I am really not into TypeScript nor Angular, but your question basically asks how to eval TypeScript source at run time, just like this question did before. So I won't use mjolnir here, but if you think your question indeed is the same as this one, let me know, so I can link them together.

    – Kaiido
    Mar 26 at 3:11

















  • I am really not into TypeScript nor Angular, but your question basically asks how to eval TypeScript source at run time, just like this question did before. So I won't use mjolnir here, but if you think your question indeed is the same as this one, let me know, so I can link them together.

    – Kaiido
    Mar 26 at 3:11
















I am really not into TypeScript nor Angular, but your question basically asks how to eval TypeScript source at run time, just like this question did before. So I won't use mjolnir here, but if you think your question indeed is the same as this one, let me know, so I can link them together.

– Kaiido
Mar 26 at 3:11





I am really not into TypeScript nor Angular, but your question basically asks how to eval TypeScript source at run time, just like this question did before. So I won't use mjolnir here, but if you think your question indeed is the same as this one, let me know, so I can link them together.

– Kaiido
Mar 26 at 3:11












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55348991%2fhow-does-web-worker-call-methods-defined-in-typescript-class%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55348991%2fhow-does-web-worker-call-methods-defined-in-typescript-class%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현