Implementing a streaming approach in your Effect project can be achieved by using the `Stream` mo...

I'm writing a little deep research implementation as my first Effect project I'd like to start to turn this into a streaming approach, starting with just emitting things at steps like "Crawling site xyz" "Searching for xyz" etc. I was wondering what the most ergonomic way to do this is? Where basically I'd have:

// Would be a Stream<string>
const agentLoop = Effect.gen(function*() {
  while (true) {
    const plan = yield* getPlan()
    // Emit message
    const queries = yield* getQueries(plan)
    const crawlResults = yield* Effect.all(
      queries.map((query) =>
        crawlSite(query).pipe(
          Effect.tap(() => {
            // Emit message
          }),
          Effect.flatMap((result) => summarizeSite(result)),
          Effect.tap(() => {
            // Emit message
          })
        )
      )
    )
  }
})
`
Was this page helpful?