Closed toranb closed 11 years ago
All existing mixins don't need to be included into ember core. You can very easily add this file into your asset pipeline and use it just as is. Just as there are a few open source mixins here and there. Take a look at what there is at emberjs-addons for example.
I don't think this really fits into ember core.
agreed, not in the current state at last...
But ember-data should definitely support pagination "out of the box", maybe through some kind of sparse array
The way I see it, the ember-data pagination should allow retrieving batches of records to avoid making one very big and long query.
Agreed on the point that "not every mixin / idea" should be in the core but I see the philosophy of ember as "if 90% of developers will need to write this by hand anyway" -why not give them tested / well written code that does just this. I feel the Ember.SortableMixin must have been a similar story (everyone needs to sort / paginate / search the ArrayController so why not provide support out of the box)
@toranb I agree with you, but the functionality we put in core should be more generic.
I would be in favor of ActiveRecord-like methods limit
and offset
on RecordArray. We would need to find a way to chain them with other methods though.
Can't say I disagree completely but I'm having a hard time selling ember (the best mvc framework to date IMHO) to my team when other frameworks get you so much "CRUD stuff" out of the box and I'm left saying "but we just need to add this mixin ...". I understand that Ember is about building ambitious web apps but I've found that learning a framework this size takes time and getting to the point where you need it can be painful when you are writing / copying code that is essential to just about any web app (CRUD or not). If nothing else thanks for the discussion (and the awesome mixin you wrote -it will be used on my personal stuff without question!)
@toranb For the most part, the CRUD stuff other frameworks is barely a skeleton, especially in Backbone's case. Don't look at it as a list of checkboxes, look at the actual code and what it really does for you. As to whether or not we include a pagination mixin, I think it depends on the percentage of apps that will have a need for it. If the vast majority would make use of it, then we should include it. If not, it should be a separate addon.
@wagenet you can probably close this one.
I think that lack of pagination in ember will frustrate average emberjs users. It's essential. Ember-data could have support for offset
and limit
options in finders and also support meta objects https://github.com/rails-api/active_model_serializers/commit/6780cd3df5b14d85a7fd032af961853a9eb7c2cf in JSON responses.
Thus response will be:
{ "meta": { "total": 1000 }, "people": [{"name": "John Doe"}, {"name": "Jane Doe"}] }
App.Person.all(2, 5) // offset and limit
can return special proxy with total
property from meta object along with first class citizens like isLoaded
, etc.
It's nothing really matters how, by plugin or mainline. Pagination just should be.
+1 for adding this to the core. It's one of those things which you really want in most of the apps.
+1 Pagination is very essential functionality
Either +1 or a guide how to handroll w/ ember seeing as it's so common
If anyone is looking for an up to date RC1 friendly pagination example, I just got this working (back button support with the router included) https://github.com/toranb/ember-django-rest
@toranb This is a client-side example and does not take into account meta so I'd say at this level this functionality can live as a stand-alone mixin. Nice work on the routes btw, the sort route is definitely something useful not sure if bookmarking a particular page is, though at least it affords history functionality.
What we do need support for is obtaining the meta information (#124) and paginating by things like 'limit' etc.
@loadx agreed -this solution doesn't scale up very well. But doesn't a true server side pagination solution depend more on ember-data than the mvc part of ember itself?
Absolutely, which is why I should of pointed out that 124 was an ember-data ticket. (https://github.com/emberjs/data/issues/124)
Cheers.
+1
+1
+1
+10
my vote is pagination as an addon: http://emberaddons.com/
I'll put together a JSBin showing how to paginate. I agree as an add-on. I think people will be happy if we at least show them how to do it.
On Jun 28, 2013, at 1:43 PM, Stefan Penner notifications@github.com wrote:
my vote is pagination as an addon: http://emberaddons.com/
— Reply to this email directly or view it on GitHub.
Ideally, it would also show a way to make requests to the back-end one page at a time, as opposed to loading the whole dataset and paging through in on the client only.
For those who want to see an example of pagination with ember, the jsfiddle below shows a pure client side pagination mixin and how to use it with a vanilla ArrayController.
The full blown project is on github and the pagination mixin is unit tested with jasmine for those interested
https://github.com/toranb/ember-pagination-example
About the issue itself, I've changed my stance and don't think this should be in the core of ember.js. I think the core of ember should be very focused and the pagination mixin makes for a great add on (thanks to @stefanpenner for the link above).
I've been playing with ember off and on the last month or so and it seems one of the basic features missing that would help make any web developer productive from day one is support for pagination.
I threw this very question out to the stackoverflow community and it looks like one of the ember contributors @tchak already has a well written mixin for pagination.
https://gist.github.com/1559628
Would it be possible to roll this into a release in the future?