Partial application of `func`
tom-sherman opened this issue · comments
Tom Sherman commented
The gist of this feature is the ability to only supply a subset of dependencies to a function as a form of partial application/auto-currying.
Example
const add = (a: number, b: number) => a + b;
const container = createContainer()
.register('one', value(1))
.register('addOne', func(add, 'one'));
const addOne = container.resolve('addOne'); // (b: number) => number
Current workarounds
Essentially just curry the function yourself
const add = (a: number) => (b: number) => a + b;
const container = createContainer()
.register('one', value(1))
.register('addOne', func(add, 'one'));
const addOne = container.resolve('addOne'); // (b: number) => number
Questions
- Should this be supported by
func
or a new operator instead?