Condividi tramite


Announcing datajs version 0.0.3

Today we are very excited to announce a new release of datajs. The latest release of datajs makes use of HTML5 storage capabilities to provide a caching component that makes your web application more interactive by reducing the impact of network latency. The library also comes with a pre-fetcher component that sits on top of the cache. The pre-fetcher detects application needs and brings in the data ahead of time; as a result the application user never experiences network delays. The pre-fetcher and the cache are fully configurable. The application developer can also specify which browser storage to use for data caching; by default datajs will pick the best available storage.

The following example shows how to setup the cache and load the first set of data.

var cache = datajs.createDataCache({
    name: "movies",
    source: "https://odata.netflix.com/Catalog/Titles?$filter=Rating eq 'PG'"
});

// Read ten items from the start
cache.readRange(0, 10).then(function (data) {
    //display 'data' results
});

The createDataCache has a ‘name’ property that specifies the name that will be assigned to the underlying store. The 'source' property specifies the URI of the data source. The source property follows the OData URI convention (to read more about OData visit odata.org). The readRange takes the range of items you want to display on your first page. 

The application developer has full control over size of the cache, the pre-fetch page size, and the lifetime of the cached items. . For example one can define the pageSize and the prefetchSize as follows:

var cache = datajs.createDataCache({
    name: "movies",
    source: "https://odata.netflix.com/Catalog/Titles?$filter=Rating eq 'PG'",
    pageSize: 20,
    prefetchSize: 350
});

This release also includes a standalone local storage component which is built on HTML5. This is the same component that the datajs cache components use for offline storage. If you are not interested in the pre-fetcher you can directly use the local storage API to store items offline. datajs local storage gives you same storage experience no matter which browser or OS you run your application on.  

You can get the latest drop of datajs library from: https://datajs.codeplex.com/. You can also get the latest version of the sources, which are less stable, but contain the latest features the datajs team is working on. Please visit the project page for detailed documentation, feedback and to get involved in the discussions.

datajs is an open source JavaScript library aimed at making data-centric web applications better. The library is released under the MIT license; you can read the earlier blog post on datajs here, or visit the project release site at https://datajs.codeplex.com.

Asad Khan
Program Manager
Microsoft

Comments

  • Anonymous
    April 18, 2011
    Really cool news of us, who wanted to use html5 local storage stuffs with minimal effort. datajs is really a great addition in developer community in this regard. Thanks for the nice API.