Using importScripts() in worker

0 favourites
  • 5 posts
  • Hi Ashley, is there any way to use importScripts("https://scripturl.js") in runtime?

    Currently I get this error when trying to use importScripts() in Worker Mode:

    TypeError: Failed to execute 'importScripts' on 'WorkerGlobalScope': Module scripts don't support importScripts().

    As the use of workers is increasing, I would like to give support for workers in Firebase.

    Firebase includes functions in its object and uses a circular structured object. So, it cant be Posted to the runtime from domside, and hence, cant be used from runtime directly. Even if it could I dont think we could run Firebase in different threads.

    If I completely resort to using domside only for Firebase functions, I think async functions will stop supporting the use of "Wait for previous actions to complete" action in the eventsheet and thus events using this Wait action will fail.

    Or am I wrong here? Can we use "Wait for previous actions to complete" for async scripts running in domside.js?

    Thankyou.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Construct uses modules, and in module workers JavaScript does not allow use of importScripts(). Use import() instead.

  • Thanks Ashley helped a lot..

    If you have some time to spare (although I know you dont), can you provide an answer to this question too? Thanks a lot.

    If I completely resort to using domside only for Firebase functions, I think async functions will stop supporting the use of "Wait for previous actions to complete" action in the eventsheet and thus events using this Wait action will fail.

    Or am I wrong here? Can we use "Wait for previous actions to complete" for async scripts running in domside.js?

  • I'm not sure what you mean - async actions can do anything async at all, which includes posting to the DOM and back. The runtime doesn't care what the method does, it just waits for it.

  • Thanks. I got it. I was doing it wrong before.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)