Effect CommunityEC
Effect Communityβ€’3y agoβ€’
76 replies
bigpopakap

Convenience Methods for Service Function Access

Convenience methods to access service functions: is this a good pattern or not?

interface SomeService {
   readonly getString: Effect.Effect<never, never, string>;
   readonly getNumber: Effetc.Effect<never, never, number>;
}

export const SomeService = Context.Tag<SomeService>();

// Is this helper good?
export const getString: Effect.Effect<SomeService, never, string> =
    pipe(SomeService, Effect.flatMap(ss => ss.getString));

// Is this helper good?
export const getNumber: Effect.Effect<SomeService, never, number> =
    pipe(SomeService, Effect.flatMap(ss => ss.getNumber));
Was this page helpful?