It looks like you're trying to create a tag for a transaction context and provide it as an option...

Is this the right way to build a tag that is going to be provided ad-hoc and read as an optional service?
type Tx = PgTransaction<
    NodePgQueryResultHKT,
    Record<string, unknown>,
    ExtractTablesWithRelations<Record<string, unknown>>
>;

export class TransactionContext extends Context.Tag("TransactionContext")<
    TransactionContext,
    Tx
>() {
    static provide = <A, E, R>(self: Effect.Effect<A, E, R>, tx: Tx) =>
        Effect.provide(self, Context.make(this, tx));
}

The docs on optional services use Effect.provideService instead and I'm not sure if I'm making anything wrong here, never services as ad-hoc as this
Was this page helpful?