laconia icon indicating copy to clipboard operation
laconia copied to clipboard

How might we abstract require?

Open hugosenari opened this issue 4 years ago • 0 comments

Is your feature request related to a problem? Please describe. We usually need to import/require other files, high coupling files.

This discussion are about how we could improve, avoid this.

Describe the solution you'd like Use 'requirejs' updated for nowdays JS. Something like this:


// services/print.js

module.exports = laconiaContext =>
  (...args) =>
    console.log(...args);
// index.js

// S will import 'services/print'
const app = (event, { S: { print } }) => 
  print(event);

const handler = laconia(app)
  .register(S)

Good

  • low coupling
  • easyer to test/mock

Bad

  • Tooling
  • Mocked unit test are less confident

Ugly

I'm not good with naming things that's why laconiaS (for app 'services') and laconiaR (for 'required')

The discussion are, how could we improve it to add as part of laconia packages, if we should ;-) .

hugosenari avatar Aug 27 '20 21:08 hugosenari