You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of using $.depends which is a function, it is maybe better to use $inject since it is more known and may be more understood.
It will introduce breaking changes.
Use cases
I often end up creating files that exports a function like this which introduce a lot of boilerplate only to allow customizing services/deps name:
module.exports=initDBService;functioninitDBService($,name='db',dependencies=['ENV']){return$.service(name,$depends(dbService));}functiondbService({ENV}){/// actual service code}
Just thought that the problem is not in the fact that $.depends is a function but instead that it is tied to a Knifecycle instance which is a non-sense since it could be pure. It would lead to code looking like that:
importdependsfrom'knifecycle';// note there are no `/instance`module.exports=depends(['ENV'],dbService);functiondbService({ENV}){/// actual service code}
It also solves the bind problem. That said, it worth considering using the $inject property anyway instead of the the current one since it is the de facto standard (used in Angular and Intravenous).
Feature description
Instead of using
$.depends
which is a function, it is maybe better to use$inject
since it is more known and may be more understood.It will introduce breaking changes.
Use cases
I often end up creating files that exports a function like this which introduce a lot of boilerplate only to allow customizing services/deps name:
Which is later used like this:
It would be more concise to do this:
And use it that way:
The only con is that some people could forget the bind and this would create some weird behaviors.
The text was updated successfully, but these errors were encountered: