Reading Next Page of Objects when Required

I have a big data table and I need to retrieve next set of page when required. I have the below code and it works without any errors. Not sure if its the correct way. I took some examples from https://backendless.com/feature-17-data-paging-or-how-to-efficiently-load-large-data-sets-in-a-mobile-app/ link.



 var async = new Backendless.Async(function(r) {
 $scope.remoteData = r;


 if ($scope.remoteData.data.length > 0) {
 $scope.dataItems = $scope.dataItems.concat($scope.remoteData.data);
 }, function() {
 });


var offset = $rootScope.remoteData.offset;


 $rootScope.remoteData.nextPage(async);


 $rootScope.remoteData = $rootScope.remoteData.getPage(offset+20, 20);

Please advise if the logic needs to be changed for better optimized performance.

The nextPage call uses the pageSize from the original query to get the next page of data.

The getPage call uses specific values for the offset and page size.

Regards,
Mark

So you mean, I should be using either nextPage or getPage and not both?

Can you please point me a simple example where I can get next page without going any loop as shown in linked examples?

If you look at the “feature 17” example it shows how to get a page. You do not need to go into a loop, the example does it just to demonstrate how to load ALL data. If you do not need it all, just use a single API method.

Unless there is an AngularJs wrapper available, its going to make it look difficult for many AngularJs users.

By “AngularJs wrapper” you mean an angularjs module that would give access to all the same APIs which we already have in backendless.js?

Yes exactly. An AngularJs version of the Javascript API.

So we’re talking about a tiny ability to import our library into your app (which you can do now, but not in the most angular-orthodox way) and that hinders your ability on using the entire library?? ))

I am talking about the whole picture here. Frameworks like Ionic use AngularJs and way developers use other libraries are mostly “angularized”.

The requirement for AngularJs lib for Backendless is not just for a a given functionality. For example, have a look on the AngularFire library provided by Firebase for their service. It has everything that an AngularJs developer would need to work with Firebase.

backendless.js has everything a developer needs to work with backendless. Your issue is you want it to be imported into your app in a specific way… and that somehow stops you from using the entire library.

There is no second thought on the features available in backendless.js.

TL;DR version : Having AngularJS specific version on BackendLess will attract more AngularJs developers to use it and reduce the number of tickets/issues/question in the forum. :slight_smile:

My point is this: the “angular specific version of backendless” you mention makes little sense for the reason that all APIs we provide are framework agnostic. The way our APIs can be used, whether is is user registration, login, object persistence or retrieval, makes no difference whether you call it from Angular, pure JS or a jQuery app.

What stops you from doing Backendless.Data.of( DataClass ).find right now in your angular app? Is there a single reason you cannot use it AS-IS?

Mark

As I mentioned there is no problem in using the API as-is. The development experience would be MORE awesome if it has more angularness like features such as promises or even friendly directives. (Is that too much to ask? :slight_smile: )

It was just my thought or a suggestion for your great team to attract more developers. The call is yours. Thanks for your time.

No, this is reasonable. I also would like to remind that the library is open-source and anyone is welcome to fork it, make changes and send us pull requests with any improvements.