Worker not Receiving PubSub Messages
Hi, I have a following simplified program for training PubSubs, could anyone help with understanding why my worker doesn't receive the message?
import { Console, Context, Effect, Layer, PubSub } from 'effect';
const pubSub = PubSub.unbounded<string>();
class SomePubSub extends Context.Tag('SomePubSub')<
SomePubSub,
PubSub.PubSub<string>
>() {}
const SomePubSubLive = Layer.effect(SomePubSub, pubSub);
const worker = Effect.gen(function* () {
yield* Console.log('Starting to listen for users to invite');
const pubsub = yield* SomePubSub;
const dequeue = yield* pubsub.subscribe;
yield* dequeue.take.pipe(Effect.andThen(Console.log));
yield* Console.log('Ended listening for users to invite');
});
const producer = Effect.gen(function* () {
const pubsub = yield* SomePubSub;
yield* pubsub.publish('user1');
});
await Effect.runPromise(
Effect.gen(function* () {
yield* Effect.fork(worker);
yield* producer;
}).pipe(Effect.scoped, Effect.provide(SomePubSubLive)),
);import { Console, Context, Effect, Layer, PubSub } from 'effect';
const pubSub = PubSub.unbounded<string>();
class SomePubSub extends Context.Tag('SomePubSub')<
SomePubSub,
PubSub.PubSub<string>
>() {}
const SomePubSubLive = Layer.effect(SomePubSub, pubSub);
const worker = Effect.gen(function* () {
yield* Console.log('Starting to listen for users to invite');
const pubsub = yield* SomePubSub;
const dequeue = yield* pubsub.subscribe;
yield* dequeue.take.pipe(Effect.andThen(Console.log));
yield* Console.log('Ended listening for users to invite');
});
const producer = Effect.gen(function* () {
const pubsub = yield* SomePubSub;
yield* pubsub.publish('user1');
});
await Effect.runPromise(
Effect.gen(function* () {
yield* Effect.fork(worker);
yield* producer;
}).pipe(Effect.scoped, Effect.provide(SomePubSubLive)),
);