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

Accessing this from within the infinityModelLoaded() method #300

Closed
sunkup opened this issue Jul 3, 2018 · 2 comments
Closed

Accessing this from within the infinityModelLoaded() method #300

sunkup opened this issue Jul 3, 2018 · 2 comments

Comments

@sunkup
Copy link

sunkup commented Jul 3, 2018

Hi!

I am learning ember. Help for using your plugin is much appreciated. It's a quick question.

Inside the infinityModelLoaded() method, this refers to something else (the infinity service?) than I am used to. I want to write the state (loaded/not-loaded) to a service. How can I access a service with this.get("myService") from within the infinityModelLoaded() method?

Thank you.

@snewcomer
Copy link
Collaborator

@extremesonic Hi! 👋 I updated the README based on your comments. It definitely needed to be improved. So thank you for bringing it up. You need to essentially pull it off the route and pass to the extended infinity model like so

export default Route.extend({
  myService: inject(),

  model() {
    return this.infinity.model('post', {}, ExtendedInfinityModel.extend({ myService: this.myService });
  }
});

Then you will have access to this service in the event hooks. Lmk if you have any other questions!

https://github.com/ember-infinity/ember-infinity#model-event-hooks

@sunkup
Copy link
Author

sunkup commented Jul 7, 2018

Thank you!

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

2 participants