(definition: D, data: Data<D>, options?: PublishOptions)
| 417 | } |
| 418 | |
| 419 | function publish<D extends Definition>(definition: D, data: Data<D>, options?: PublishOptions) { |
| 420 | return Effect.gen(function* () { |
| 421 | const serviceLocation = Option.getOrUndefined(yield* Effect.serviceOption(Location.Service)) |
| 422 | const location = |
| 423 | options?.location ?? |
| 424 | (serviceLocation |
| 425 | ? { directory: serviceLocation.directory, workspaceID: serviceLocation.workspaceID } |
| 426 | : undefined) |
| 427 | return yield* publishEvent( |
| 428 | definition, |
| 429 | { |
| 430 | id: options?.id ?? ID.create(), |
| 431 | ...(options?.metadata ? { metadata: options.metadata } : {}), |
| 432 | type: definition.type, |
| 433 | ...(location ? { location } : {}), |
| 434 | data, |
| 435 | } as Payload<D>, |
| 436 | options?.commit, |
| 437 | ) |
| 438 | }) |
| 439 | } |
| 440 | |
| 441 | function replay( |
| 442 | event: SerializedEvent, |
nothing calls this directly
no test coverage detected