How to create & use a provider in 5.0.0-preview-rc-1.7?

In the v4.1 docs I see that I can make a new provider by extending ServiceProvider then using this.app to associate it with some namespace (register it) and then it can be injected into other code by const SomeProvider = ioc.use('Foo/Bar/Baz').

In the 5.0 preview, it looks like instead of ioc.use it’s possible to do something like import MyProvider from '@ioc:Foo/Bar/MyProvider'. However, when I look at AppProvider.ts or the file produced by running node ace make:provider ... there’s no corresponding base class, so I don’t see how to do the equivalent of this.app....

Does the framework automatically set the name somehow based on filename by default??

1 Like

I think I can now, at least partially, answer my own question:
The constructor function here is using the Parameter properties of TypeScript, so that this.container is available, and this appears to function much like this.app

Nope. You have to define it yourself inside provider
You can take a Redis provider as example:

2 Likes