Register single dependency
See original GitHub issueIs your feature request related to a problem? Please describe. When I need to register a single dependency, the current Laconia API is asking me to return an object, which lead to a verbose code.
const instances = ({ env }) => ({
orderStream: new KinesisOrderStream(env.ORDER_STREAM_NAME)
});
exports.handler = laconia(kinesis(app))
.register(instances);
Describe the solution you’d like
exports.handler = laconia(kinesis(app))
.register("orderStream", ({env}) => new KinesisOrderStream(env.ORDER_STREAM_NAME) );
This will also allow users to decouple their factories better from Laconia:
exports.handler = laconia(kinesis(app))
.register("orderStream", ({env}) => myOwnFactory(env.ORDER_STREAM_NAME) );
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Dependency injection in ASP.NET Core | Microsoft Learn
The ASP.NET Core framework uses a convention for registering a group of related services. The convention is to use a single Add{GROUP_NAME} ...
Read more >Is there a easier way to register dependencies when I want ...
In C#, of course, many dependencies can be registered for DI with one short line via Microsoft.Extensions.DependencyInjection, especially ...
Read more >Registering Types with Prism
For those who may be familiar with ASP.NET Core you may be familiar with 3 basic types of dependency registrations: Transients, Singletons, and...
Read more >Dependency Injection in ASP.NET Core - TutorialsTeacher
Learn about dependency injection in ASP.NET Core application. Undestand built-in IoC Container and basic registration of application services and its ...
Read more >Instance Scope — Autofac 6.0.0 documentation
When a request is made for a service, Autofac can return a single instance (single instance scope), a new instance (per dependency scope),...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Suggestion, add helper to convert to expected type:
usage:
@hugosenari I didn’t realize how difficult it is to overload things in JavaScript, my bad. Maybe adding a new method is a good way to go, I’ll continue the conversation in the PR.