Skip to content

Commit

Permalink
Merge pull request #2 from Gavant/allow-recordarray-instances
Browse files Browse the repository at this point in the history
Allow DS.RecordArray usage
  • Loading branch information
bakerac4 committed Jul 11, 2019
2 parents 3583923 + fc4def3 commit a64a8ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion addon/decorators/route-pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import { PaginationController, buildQueryParams } from '@gavant/ember-pagination
export default function routePagination<T extends ConcreteSubclass<any>>(RouteSubclass: T) {
class PaginationRoute extends RouteSubclass {
setupController(controller: PaginationController, model: any) {
assert('Model is not an instanceof DS.AdapterPopulatedRecordArray. In order to use the RoutePaginationMixin, the model returned must be an instance of DS.AdapterPopulatedRecordArray which comes from using store.query', model instanceof DS.AdapterPopulatedRecordArray);
assert(
'Model is not an instanceof DS.AdapterPopulatedRecordArray. In order to use the RoutePaginationMixin, the model returned must be an instance of DS.AdapterPopulatedRecordArray or DS.RecordArray which comes from using store.query',
model instanceof DS.AdapterPopulatedRecordArray || model instanceof DS.RecordArray
);

setProperties(controller, {
modelName: model.type.modelName,
Expand Down
6 changes: 5 additions & 1 deletion addon/mixins/route-pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export default Mixin.create({
* @param model - The result returned from a `store.query`
*/
setupController(controller: PaginationController, model: any) {
assert('Model is not an instanceof DS.AdapterPopulatedRecordArray. In order to use the RoutePaginationMixin, the model returned must be an instance of DS.AdapterPopulatedRecordArray which comes from using store.query', model instanceof DS.AdapterPopulatedRecordArray);
assert(
'Model is not an instanceof DS.AdapterPopulatedRecordArray. In order to use the RoutePaginationMixin, the model returned must be an instance of DS.AdapterPopulatedRecordArray or DS.RecordArray which comes from using store.query',
model instanceof DS.AdapterPopulatedRecordArray || model instanceof DS.RecordArray
);

setProperties(controller, {
modelName: get(model, 'type.modelName'),
metadata: get(model, 'meta'),
Expand Down

0 comments on commit a64a8ba

Please sign in to comment.