Closed manuel-schoebel closed 9 years ago
Hey @DerMambo
Currently there is no such pattern available by default, but you can completely customize the Space.Injector
used by your Space.Application
, just create your own instance and hand it over when creating your app instance:
class CustomInjector extends Space.Injector
# override the way injections happen
injectInto: (value) ->
super # normal behavior first
value.Logger = MyGlobalLoggerInstance
customInjector = new CustomInjector
myApp = new MySpaceApp injector: customInjector # hand custom injector over to app instance
Hope this helps!
PS: Awesome! I will release 4.0 of space:ui
next week, cleaned up and with support for strongly-checked events :-)
Cool, yes that helps. I will do that and publish it to the world! :P
Nice, looking forward to 4.0 :)
Great! :smile: If you need more control or custom ways to provide dependencies to your code you can also add custom providers to the injector instance. I wrote a little bit about it in the Space.Injector docs
Hi @DominikGuzei,
is there a good way to have a global object or one that is automatically injected everywhere?
The reason is that I have a Logger-Module which I would need anytime.
Cheers, Manuel
PS: I am still enjoying space! :)