Clarification on Using `Stream.share` in Effect Typescript

It's not totally clear to me how Stream.share is meant to be used. It looks like if I have a single stream and I want to return it to a consumer and then also process it in a separate fiber, I have to call Stream.share twice, is that right?

Basically:

const getStream = E.gen(function*() {
  const stream = yield* createStream;

  const streamB = yield* Stream.share(stream, {
    capacity: "unbounded",
  });

  const streamC = yield* Stream.share(streamB, {
    capacity: "unbounded",
  });

  yield* E.forkDaemon(streamC.pipe(processStream))

  return streamB
});


Something about this makes me feel like I'm doing something wrong, though.
Was this page helpful?