Closed e00dan closed 1 year ago
Maybe it's not an issue but I'm also interested in this topic.
I wrote a guide to rolling your own services in Glimmer: https://gist.github.com/mixonic/acbc9b8d57819e2f2c77b206ab7f422e
This is the kind of thing that would be great to put into an addon once we have that part of the infrastructure more fleshed out.
@mixonic thanks for the response :) I already found your solution and gave it a try. I already discussed this topic with @locks in the slack channel. The conclusion was something like "it's not that easy". But I think services are a great way to split functionality and to organize code. Also they make testing easier. So I would love to see services as a "first class citizen" in glimmer.
Hey, great job with the library! I love the Ember CLI, TypeScript and Glimmer! However, I've got a question for you - is is possible to somehow do service: Ember.inject.service() like in Ember? You write a lot about container, registry and Dependency Injection, but no examples how we could take advantage over this for example in Component (or maybe it's there, but I'm confused...). Is is possible to get container reference in component.ts or create something like service? :)
Should I create a typescript file which exports instance instead of class and that's it? Would it be Glimmer way?
Or should I create an injection globally?
registry.registerInjection('component', 'store', 'store:main')
But I don't want to inject my instances everywhere. :)
I think I could also globally register something like container and then access individual objects on that object. But still doesn't feel great.