Neek Sandhu (2018-07-17T06:26:00.000Z)
neek.sandhu at outlook.com (2018-07-17T06:31:14.895Z)
Ok maybe you guys are not impressed enough š Hereās a 339 line file and [on Line 85 thereās a variable called `workerInitPromise`](https://github.com/NeekSandhu/v-thread/blob/ed350bd4dcbf8e368cea2b3819f405b61ef783a3/src/MainThread.ts#L85) Only one method in that class is concerned with `workerInitPromise`, that is `startWorker()` What is `workerInitPromise`? Well, whenever [`startWorker()`](https://github.com/NeekSandhu/v-thread/blob/ed350bd4dcbf8e368cea2b3819f405b61ef783a3/src/MainThread.ts#L236) is called it should return a `Promise` that should resolve when the `Worker` is up and running. That means one call to `startWorker` has started the worker startup sequence and itād be wasteful to start it over again when someone else calls `startWorker`. Instead `startWorker` decides to āshareā the `Promise` amongst furious callers. Now, `startWorker` needs a place to store that `Promise` so he can share with subsequent callers. Where is that place??? And that my friends is why I had to create `workerInitPromise` prop on the class, just to make `startWorker` happy. It ābelongsā in `startWorker` and should āliveā inside `startWorker`