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

Concept of service/access to container in Glimmer application? #44

Closed
e00dan opened this issue Jun 17, 2017 · 3 comments
Closed

Concept of service/access to container in Glimmer application? #44

e00dan opened this issue Jun 17, 2017 · 3 comments

Comments

@e00dan
Copy link

e00dan commented Jun 17, 2017

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.

@tschoartschi
Copy link

Maybe it's not an issue but I'm also interested in this topic.

@mixonic
Copy link
Member

mixonic commented Aug 23, 2017

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.

@tschoartschi
Copy link

@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.

@e00dan e00dan closed this as completed Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants