Effect CommunityEC
Effect Community3y ago
32 replies
imagio

Designing Services: Utility Functions on the Service or "Loose" Utility Functions?

Style question -- When designing services which style do people prefer for organization?

1. Put utility functions on the service

interface MyService { foo: string,  doSomeStuff(): T.Effect<....> }

//use it
pipe(....,
  T.flatMap(MyService, s => s.doSomeStuff()),
   ....
)


or 2. Write "loose" utility functions that consume the service

interface MyService { foo: string }
export const doSomeStuff = () => T.flatMap(MyService, s => pipe(....do the same stuff....))

//use it
pipe(....,
  doSomeStuff(),
   ....
)
Was this page helpful?