( group: EventGroup.EventGroup<Events>, f: (handlers: Handlers<never, Events>) => Handlers.ValidateReturn<Return> )
| 531 | * @since 4.0.0 |
| 532 | */ |
| 533 | export const group = <Events extends Event.Any, Return>( |
| 534 | group: EventGroup.EventGroup<Events>, |
| 535 | f: (handlers: Handlers<never, Events>) => Handlers.ValidateReturn<Return> |
| 536 | ): Layer.Layer< |
| 537 | Event.ToService<Events>, |
| 538 | Handlers.Error<Return>, |
| 539 | Exclude<Handlers.Services<Return>, Scope.Scope | Identity> | Registry |
| 540 | > => |
| 541 | Layer.effectDiscard( |
| 542 | Effect.gen(function*() { |
| 543 | const registry = yield* Registry |
| 544 | const context = yield* Effect.context<Exclude<Handlers.Services<Return>, Scope.Scope | Identity>>() |
| 545 | const result = f(makeHandlers({ |
| 546 | group: group as EventGroup.AnyWithProps, |
| 547 | handlers: {}, |
| 548 | context |
| 549 | }) as unknown as Handlers<never, Events>) |
| 550 | const handlers = Effect.isEffect(result) |
| 551 | ? (yield* (result as unknown as Effect.Effect<Handlers<any>>)) |
| 552 | : (result as unknown as Handlers<any>) |
| 553 | for (const tag of Object.keys(handlers.handlers)) { |
| 554 | registry.registerHandlerUnsafe({ event: tag, handler: handlers.handlers[tag] }) |
| 555 | } |
| 556 | }) |
| 557 | ) as any |
| 558 | |
| 559 | /** |
| 560 | * Registers a compaction handler for an event group. |
nothing calls this directly
no test coverage detected