When you have a large amount of data, it is often beneficial to present it in paged format so that you don't have to load all of it at once. In this recipe, we will create an app with several pages of data that will require server-side pagination.
For this recipe, we will use a library called Chance
to generate a large set of random data. Chance is composed of various functions that allow us to get all sorts of random data to test with. So, it is ideal to mock up data before you have any. It can be installed by running npm install chance
in your command line.
To do server-side pagination using Socket.IO, follow these steps:
First, we will create our new Cordova app by running
cordova create app com.server.paginationserverPagination
.Next, we will add the iOS platform by running
cordova platform add ios
, and build it by runningcordova build ios
.Now, we will create our
server.js
file. We will generate around hundred random items when the...