AshleyScirra/via.js

'via' is not defined

MaxPowerReforged opened this issue · 1 comments

I am using via.js in a React (CRA) context in order to do some DOM manipulation in web workers. In the docs we can see this example:

const document = via.document;
const button = document.createElement("button");

However, I cannot instance nor access any via object with which to work. I am importing the four source files (receiver, controller, object, property). Probs I am missing something :)

Thanks!

self.via is defined in controller.js here: https://github.com/AshleyScirra/via.js/blob/master/via/controller/controller.js#L63

You must not include all four scripts in the same JavaScript context. The receiver and controller scripts must be used in different contexts. Just make sure you include the controller scripts in the context you're trying to use via globally, and that your code runs after the scripts have loaded.