Using `Effect.repeat` with a schedule will indeed return the number of repetitions rather than th...

I'm trying to wait for a WebView to be available in my VS Code extension, but I'm not sure how to make it work properly, because
Effect.repeat
returns
number
, not the value of the effect itself.

Here's my code so far:

export const waitForWebView = (extensionUri: vscode.Uri, isProduction: boolean) => Effect.gen(function*() {
  const webview = FlytrapView.getInstance(extensionUri, isProduction)._view?.webview
  if (webview === undefined) {
    return yield* Effect.fail(`Webview not yet initialized.`)
  }
  return webview
}).pipe(
  Effect.repeat(Schedule.addDelay(
    Schedule.recurs(15),
    () => "200 millis"
  ))
)


I need to get the webview to be returned from the waitForWebView, how would I achieve this? Thank you in advance!!
Was this page helpful?