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

Extend InfinityModel #222

Closed
3 of 4 tasks
snewcomer opened this issue Jun 12, 2017 · 4 comments
Closed
3 of 4 tasks

Extend InfinityModel #222

snewcomer opened this issue Jun 12, 2017 · 4 comments
Assignees

Comments

@snewcomer
Copy link
Collaborator

snewcomer commented Jun 12, 2017

  • Expose infinityModel constructor to people to extend in their own apps
  • Allow them to pass a class into the infinityModel that should be extended - i.e. as third argument in Route.
  • improve documentation (also alluding to Ensure works with JSONAPI pagination requirements #97 as well)
  • public getter for infinityModels. Something like route#getInfinityModels()
import InfinityModel from 'ember-infinity/lib/infinity-model';
const CustomInfinityModel = InfinityModel.extend({
  //..snip
})

export default Route.extend({
  model() {
    return this.infinityModel('product, { perPage: 10, startingPage: 1 }, CustomInfinityModel);
  }
})

Ref #220

Will tackle after #220

@snewcomer snewcomer self-assigned this Jun 12, 2017
@snewcomer
Copy link
Collaborator Author

More notes

// new way

const MyInfinityModelClass = InfinityModel.extend({
  global: service(),
  buildParams() {
    let params = this._super(...arguments);
    params['category_id'] = get(this, 'global.categoryId');
    return params;
  }
});

Route.extend({
  global: service(),
  categoryId: computed('global.categoryId', function() {
    return get(this, 'global.categoryId');
  }),
  model() {
    this.infinityModel('product', {}, MyInfinityModelClass);
  }
});

@snewcomer
Copy link
Collaborator Author

I'll make sure I get this issue done by the end of next week to add to the 1-0 branch.

@hhff
Copy link
Collaborator

hhff commented Aug 28, 2017

Thankyou!!

@snewcomer
Copy link
Collaborator Author

closing this after #236 was merged. Still have one checkbox outstanding. Jotting that down for another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants