Note that an import *roughly* like this is already necessary for @typescriptlang to have enough info to be usable for services today (`@service fetch!: Fetch;`) so rationalizing DI in something like this way would be
from where I stand.
-
-
Replying to @chriskrycho @TheLarkInn and
Wow! I didn't see that before! It's actually an interesting way to use TypeScript in a useful way that doesn't feel mandatory (or maybe even require runtime glue from TS) but also doesn't impose extra costs on TS users.
2 replies 0 retweets 2 likes -
Replying to @wycats @chriskrycho and
This also seems preferable independent of TS because explicit imports are the direction JavaScript itself is moving (has moved). You have to type a bit more, and it's less magic, but IMO sticking to the emerging language patterns is worth the extra typing
1 reply 0 retweets 3 likes -
Replying to @15lettermax @wycats and
Even languages that have always had static module imports still reinvent dependency injection too. They are for different things.
1 reply 0 retweets 4 likes -
Replying to @eaf4 @15lettermax and
I think part of that is because most languages don't have the shared runtime state thing that ES modules do? ES modules and CommonJS both seem to encourage sharing state through a module
2 replies 0 retweets 0 likes -
What's an example of sharing state through a module?
2 replies 0 retweets 0 likes -
Replying to @amatchneer @eaf4 and
If two modules import the same module, they get the same copy, which they can use as a location for shared state. I saw this used a lot in Node to solve similar problems to DI
2 replies 0 retweets 0 likes -
Replying to @nucknyan @amatchneer and
As an example, you might have a module which stores the database connection for your app, and then you just import connection from './db' and always get the same one
1 reply 0 retweets 0 likes -
Replying to @nucknyan @amatchneer and
It's a lot like ember services, honestly
2 replies 0 retweets 0 likes -
Replying to @nucknyan @amatchneer and
And it is classical Singleton ... from backend dev perspective I find Ember services totally OK .. and See
@chriskrycho reply - it has nice integration with TypeScript add-on.@wycats please, don't tear down the DI :)2 replies 0 retweets 1 like
No plans to do so :)
Ember services are an important part of the conventional application structure 
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.