ldez / cubejs

cube.js -- JavaScript library for modeling and solving the 3x3x3 Rubik's Cube
http://ldez.github.io/cubejs/
MIT License
315 stars 47 forks source link

How to use Web worker in cubejs? #86

Closed Aaron-Bird closed 4 years ago

Aaron-Bird commented 4 years ago

The following examples all throw errors:
Where did I go wrong? 1

const randomCube = Cube.random();
Cube.asyncInit('./lib/worker.js', function () {
  // Cannot read property '24092' of null
  console.log(randomCube.solve());
});

2

const randomCube = Cube.random();
Cube.asyncInit('./lib/worker.js', function () {
    //cube.toJSON is not a function
    Cube.asyncSolve(randomCube, function (algorithm) {
        console.log(algorithm);
    });
});

I wrote a demo here: https://github.com/Aaron-Bird/cubejs-demo