andywer / andywer/threads.js

Question: unusable sample code

未關閉
#400 1 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
documentation question
主要語言
TypeScript
星號
3.5k
分支
173
PR 合併指標
30 天內沒有已合併 PR

描述

I'm doing some usage of your package, with TypeScript.

I see [in your documentation](https://threads.js.org/usage-pool#scheduling-tasks) an example that shows:

`let pool: Pool`

Well, perhaps I'm missing something, but `ThreadType` is not exposed it seems (or, it's hidden somewhere)? Or, is this supposed to be a placeholder for something else?

I want to declare (with type information) a variable like what you've shown, but, like I said, it seems `ThreadType` is not exposed.

What's supposed to be used here?

Another issue is that when I do something like this:

```ts
const x = Pool(spawnWorker, 1);
```

VSCode is able to show me that `x` has been attributed a type of:

```
const x: WorkerPool>
```

But, again, it seems I am not able to import all of these discreet types :(

What I really want to be able to do is say that I have an object having a variable/as yet unknown number of (referenced by string key) `Pool(()=> spawn(new Worker('./worker')), 1)` results.

eg:
```ts
const spawnWorker = () => spawn(new Worker('./worker'));

const pools: {
[index: string]: WorkerPool>;
} = {};
```

so I can add to my `pools` like this:

```ts
pools['thing1'] = Pool(spawnWorker, 1);
```

But, again, `WorkerPool` and `Result` do not appear to be exposed.

A little help please?

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。