Creating a Service with a Dependency on a Single Class in Effect Typescript

Question to experts, I need to make a service that depends on a single class (need to make an obrt over it). The only idea I have how to do it is to create a separate service to store this class, but I do not like it. Does anyone have any ideas how to do it more conveniently?
class MessageContextRef extends Context.Tag("MessageContextRef")<
  MessageContextRef,
  MContext
>() {
  static Live = (self: MContext) => Layer.succeed(MessageContextRef, self)
}
const MessageContextMake = Effect.gen(function*() {
  const context = yield* MessageContextRef;
  return {
    unsafe: context,
    text: context.text,
    answerText: internal.answerText
  }
})

export class MessageContext extends Context.Tag("@MessageContext")<
  MessageContext,
  Effect.Effect.Success<typeof MessageContextMake>
>() {
  static Live = Layer.effect(MessageContext, MessageContextMake)
}

This service depends on MContext
Was this page helpful?