Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for high order functions #51

Open
mhsdesign opened this issue Apr 28, 2022 · 1 comment
Open

Support for high order functions #51

mhsdesign opened this issue Apr 28, 2022 · 1 comment

Comments

@mhsdesign
Copy link

mhsdesign commented Apr 28, 2022

i set up my project using higher-order functions for the dependencies similar to: https://medium.com/geekculture/dependency-injection-in-javascript-2d2e4ad9df49

// application/ports.ts
export interface Logger {
  log(msg: string): void;
}

// application/fooFunction.ts
interface Dependencies {
  logger: Logger;
}

export const makeFooFunction({ logger }: Dependencies ) = (foo: string) => {
   // foo bar
   logger.log("bung" + foo)
}

i was wondering if this higher-order pattern could technically also be implemented / be used for di with this project (if yes maybe i can build it myself but idk)

(fx. by setting makeFooFunction.inject = ['logger'])

@mhsdesign
Copy link
Author

uups sorry there is already https://github.com/nicojs/typed-inject#injectorinjectfunctionfn-injectablefunction

(i find this beeing to far down in the docs -> its not teasered like class di at the top)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant