Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services derived from other services #5

Closed
bazo opened this issue Jan 11, 2014 · 4 comments
Closed

services derived from other services #5

bazo opened this issue Jan 11, 2014 · 4 comments

Comments

@bazo
Copy link

bazo commented Jan 11, 2014

in nette you can write this

routerFactory: App\RouterFactory
router: @routerFactory::createRouter

i dont think this is possible with dependency-injection?

there's many packages that just expose their classes, rarely you can directly instantiate them

something like this would be really nice

{
    "services": {
        "barista": {
            "service": "barista",
            "instantiate": false
        },
        "router": {
            "service": "@barista.Router"
        }
    }
}
@davidkudera
Copy link
Member

I didn't implement everything from nette di yet, but I definitelly want, so this (@routerFactory::createRouter) is next thing what I want to add.

You are also right with instantiating libraries in js, so I created this issue: #6.

And your last example. Am I right if I say that @barista.Router will access Router property in barista object? I'm just asking because I know this dot syntax from accessing services in extensions in nette di.

@bazo
Copy link
Author

bazo commented Jan 11, 2014

many libs export more than on class/function, then you access which one you want with . and instantiate it yourself.
this is the js code

var Router = require('barista').Router;
var router = new Router;

@davidkudera
Copy link
Member

Okay, this shouldn't be a problem

@davidkudera
Copy link
Member

Accessing properties (like @barista.Router) will also have to be with ::, because you can access services also with their paths:

di.get('$path/to/barista.js.Router');     // parsed js: barista.js.Router

so because of this, it will have to look like this:

di.get('$path/to/barista.js::Router');    // parsed js: barista.Router

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants