Creating a File Data Source
In this section, I discuss how you can create a custom file data source. The file data source stores and retrieves data from the file system.
Note
The complete source code for the FileDataSource
is included in the GitHub source code in a folder named file.
The FileDataSource
includes implementations of the getCount()
, itemsFromIndex()
, insertAtEnd()
, remove()
, and change()
methods.
When you call either the getCount()
or itemsFromIndex()
methods, the FileDataSource
loads its data from the file system and calls JSON.parse()
to parse the file data into a JavaScript array. The FileDataSource
loads data in its _ensureData()
method:
_ensureData: function () { var that = this; // Attempt ...
Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.