How to Merge Two Queues into a Stream in TypeScript

Is the best way to merge two queues to merge them into a stream? I can't seem to figure out the right way to do something like this:

  const startNixTimerSubscriber = yield* pubsub.subscribeTo("StartNixTimer");
  const stopNixTimerSubscriber = yield* pubsub.subscribeTo("StopNixTimer");

  const stream = Stream.merge(
    Stream.fromQueue(startNixTimerSubscriber),
    Stream.fromQueue(stopNixTimerSubscriber),
  );

  yield* Effect.forkScoped(
    Effect.forever(
      Effect.gen(function* () {
        const message = yield* Stream.take(stream, 1).pipe(
          Stream.runCollect,
          Effect.andThen(Chunk.unsafeGet(1)),
        );

        ...
     }))
Was this page helpful?