threads.js icon indicating copy to clipboard operation
threads.js copied to clipboard

Promised Observable

Open balbatross opened this issue 1 year ago • 1 comments

Kia Ora,

We're trying to run an async function that returns an observable, because of the structure of the resultType the library tries to serialize our Observable function leading to a DataCloneError.

Would a promised-observable resultType cause confusion? Happy to put the time in for a PR.

balbatross avatar Jun 19 '23 04:06 balbatross

Try iife, like what we do in useEffect

function runLLama(
  options: { conversationID: string; modelPath: string; openDebugger?: boolean; prompt: string },
): Observable<ILanguageModelWorkerResponse> {

  return new Observable<ILanguageModelWorkerResponse>((subscriber) => {
    void (async function runLLamaObservableIIFE() {
      await xxx
    })();
  });
}

linonetwo avatar Jul 17 '23 08:07 linonetwo