export const publisher = Layer.effect(
EventPublisher,
Effect.gen(function*() {
const pubsub = yield* EventPubSub
return EventPublisher.of({
// This causes a type error:
// TypeError: Cannot read properties of undefined (reading 'current')
// at Object.get (file:///home/r24e23sdiw9w1oqo1ljpo851jbidnw-h5th/playground-1759838288856/node_modules/.pnpm/[email protected]/node_modules/effect/dist/cjs/MutableRef.js#cjs:72:26)
publish: pubsub.publish
// Use the below line instead and everything works.
// publish: msg => pubsub.publish(msg)
})
})
).pipe(Layer.provide(EventPubSub.Default))
export const publisher = Layer.effect(
EventPublisher,
Effect.gen(function*() {
const pubsub = yield* EventPubSub
return EventPublisher.of({
// This causes a type error:
// TypeError: Cannot read properties of undefined (reading 'current')
// at Object.get (file:///home/r24e23sdiw9w1oqo1ljpo851jbidnw-h5th/playground-1759838288856/node_modules/.pnpm/[email protected]/node_modules/effect/dist/cjs/MutableRef.js#cjs:72:26)
publish: pubsub.publish
// Use the below line instead and everything works.
// publish: msg => pubsub.publish(msg)
})
})
).pipe(Layer.provide(EventPubSub.Default))