puddlejumper26 / blogs

Personal Tech Blogs
4 stars 1 forks source link

useClass, useValue, useFactory, useExisting and Testing #160

Open puddlejumper26 opened 4 years ago

puddlejumper26 commented 4 years ago

https://offering.solutions/blog/articles/2018/08/17/using-useclass-usefactory-usevalue-useexisting-with-treeshakable-providers-in-angular/

useFactory takes a factory function that is expected to return the value and also can have dependencies (require instances of other providers passed as parameter)

The provide property configures the token that will be used in dependency injection and the useFactory is pointing to the function that will be used to return the desired value. The deps property configures the tokens that will be passed to your factory function.