datajs caching and paging- 2 suggestions

May 31, 2011 at 1:38 PM

I have two suggestions to you if they aren't already in your task list.
Actually I am using ebay oData service and the situation is:
I am reading categories from eBay service, using caching and paging, items per page: 10, and prefetch: 10 items. Also on a page there are 2 buttons NEXT and PREVIOUS

When page is loaded for the first time it actually calls oData service twice, first time to get first 10 items, and after that async call to prefetch next 10 items.

When I click Next button it loads next 10 items from the cache (but does not prefetch next 10 items !!!). My suggestion is to check does next 10 items are in local store, and to make async call depends of the condition.

Another suggestion is about performance issue. If I click Next button and data is not cached it initialize call to load next data. But if I don't have mechanism for preventing multiple clicks on Next Button (block UI, disable button etc.), and continue to click Next, it initiate multiple calls as :$skip=20&top=10&$callback=handleJSONP_20&$format=json$skip=20&$top=10&$callback=handleJSONP_21$format=json$skip=20&$top=10&$callback=handleJSONP_22$format=json$skip=20&$top=10&$callback=handleJSONP_23$format=json


As requests finishes it actually initiate another one call for every async "thread" - the new one is for prefetching next 10 items:$skip=30&$top=10&$callback=handleJSONP_24&$format=json$skip=30&$top=10&$callback=handleJSONP_25$format=json$skip=30&$top=10&$callback=handleJSONP_26$format=json$skip=30&$top=10&$callback=handleJSONP_27$format=json

 and in this case you are performing 6 requests unnecessary (3 for each range).

My suggestion will be to track calls to the server, so if i initiate the same call ($skip=20&$top=10)  it shouldn't initiate another call until the previous one finished.


Vlatko Ivanovski

Jun 1, 2011 at 4:41 AM

Vlatko, that just sound like a bug on our end. The cache should never ask twice for the same piece of information, and we should definitely allow multiple outstanding requests to 'next'.

If you don't want to receive the notification for a previous one (so you don't even see the results and you never get an out-of-order callback), then you can call .abort() on the result of readRange() - this will cancel the operation.

Thanks for the issue report! Are you using the latest published or the latest built-from-sources version? There are a few fixes that we've uploaded since our last download release...

Jun 1, 2011 at 6:22 PM

Minor update, the method is cancel() not abort()


Alex Trigo.