Effect CommunityEC
Effect Community14mo ago
11 replies
Jambudipa

Obtain reference to the Service class within the Service class

I want to call a protected member of my Service class within the constructed object, like this:
export class SearchService extends Effect.Service<SearchService>()('SearchService', {
  dependencies: [Language.Default],
  scoped: Effect.gen(function* () {
    return {
      search: (search: Search) =>
        Effect.gen(function* () {
          // want to call SearchService.createVectorPipeline() here...
        }),
    }
  })
}) {
  protected createVectorPipeline = (search: Search) => Effect.gen(function* () {
    // Uses a dependency of the service
    const language = yield* Language;
    const pipeline = [];
    return pipeline;
  });
}

How do I go about that? There is a scoping problem with this wherever I put it.
Was this page helpful?