Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile function is undefined under the subthread #49

Open
ktrzeciaknubisa opened this issue Jul 20, 2015 · 1 comment
Open

Mobile function is undefined under the subthread #49

ktrzeciaknubisa opened this issue Jul 20, 2015 · 1 comment
Assignees

Comments

@ktrzeciaknubisa
Copy link
Member

console.log("Main thread", typeof Mobile);

jxcore.tasks.runOnce(function(){
  console.log("Thread", process.threadId, typeof Mobile);
});
Main thread function
Thread 0 undefined
Thread 1 undefined

Workaround

So if you want to call e.g. Mobile("log").call("hello") under the task, you need to do something like this:

jxcore.tasks.runOnce(function(){
  process.sendToMain("test");
});

jxcore.tasks.on("message", function(tid, params) {
  if (params === "test")
    Mobile("log").call("hello");
});
@obastemur obastemur self-assigned this Jul 21, 2015
@obastemur
Copy link
Member

We can definitely register Mobile proxy class to subthreads to handle this sort of usage.

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

No branches or pull requests

2 participants