inversify / InversifyJS

A powerful and lightweight inversion of control container for JavaScript & Node.js apps powered by TypeScript.
http://inversify.io/
MIT License
11.15k stars 712 forks source link

Async factory #887

Open amir-arad opened 6 years ago

amir-arad commented 6 years ago

Hi

Are there any plans to support async factories?

Thanks

TheAifam5 commented 6 years ago

Maybe that help you: https://github.com/inversify/InversifyJS/blob/master/wiki/provider_injection.md

amir-arad commented 6 years ago

thanks @TheAifam5 . I've tried that and i found out that with providers, the consumer is injected with a function that returns a promise to an entity (()=>Promise<T>), instead of simply an entity (T).

What I mean by async factory is to register something like (context)=>Promise<T> and have the consumer be injected with T.

ifree92 commented 5 years ago

Actually I'm looking for the same functionality. To be able to have provided instance automatically and delegate execution async factory to inversify, instead call it manually

episage commented 5 years ago

+1, looking for the same thing for transparent Unit of Work implementation

parisholley commented 5 years ago

@amir-arad @ifree92 @episage check out #1074