josdejong/workerpool

Imported class is stated to be not defined

adokhugi opened this issue · 2 comments

In exampleWorker.ts, I import the class OctantBox:

import { OctantBox } from "../spt/OctantBox.ts";

This class is defined as an export class:

export class OctantBox

Then I have the worker function getBoxNodes in which I access OctantBox.

async function getBoxNodes(
  o: OctantBox, 
  maxLevel: number,
  rootEpoch: number,
  bounds: BoundsLatLng | BoundsLatLng[]) {
    const o1 = new OctantBox(o.path, o.octantNumber, o.box, o.children);
    let boxNodes = o1.getNodes(maxLevel, rootEpoch, bounds);
    if (boxNodes) {
      return boxNodes;
    }
    return [];
}

I execute the worker in my main code like this:

  var boxNodePromiseResult = await workerpool.Promise.all(
    octants.map((o) => pool.exec(getBoxNodes, [o, maxLevel, rootEpoch, tileBoundsLatLng]).then(function (result) {
      console.log("OctantBox", o);
    }))
  );

But I get the error message that OctantBox is not defined. What am I doing wrong?

My call of the worker function was not correct.

Ok so I understand the issue is solved. I'll close this issue now.