Incrementally Synchronize HTML5 Databases Transparently
The first release of Impel.inTouch made it simple to keep your user's HTML5 databases up-to-date with your server. All you needed to do was publish a versions file and a definition file for the most recent version of each table on your server. Then all of your client's local HTML5 databases would be quickly and transparently updated the next time they fire up your web application.
There was however one small issue: every time a user's HTML5 database table was updated via Impel.inTouch the entire table would need to be downloaded again. Today's release pushes that issue to the side. The release of Impel.inTouch includes incremental update capabilities.
Tables can now be updated in one of two ways:
- Single Update: no matter what the current version of the table is it will be updated to the absolute latest version.
- Incremental Update: the table will be updated to the next most recent version then the next most recent, and so on until it is at the latest version.
If you want the table to be updated in a single request then its entry in the versions file must consist of a table key and a version key. The version key's value should simply be the most recent version number.
If you want the table to be updated incrementally then its entry in the versions file must consist of a table key and a versions key. The versions key's value should be an array of ALL the versions of the table.
([{ "table" : "card", "version" : 1},
{ "table" : "stack", "version" : 1},
{ "table" : "similar_card", "version" : 1},
{ "table" : "card_score", "version" : 1},
{ "table" : "player", "versions" : [1,2,3,4,5,6,7]},
]);
Every table that you want to have created/updated on your client's browser must have an associated definition file. The file must have the same name as the table in the versions file. By default the suffix for the table file should be .json.php, but you can specify a different suffix when you instantiate an Impel.inTouch object.
Important note If a table is to be updated incrementally rather than in a single update the name of the table and the suffix must be seperated by "_[table_version]" for each version of the table. So in the example above, where the player table has seven versions, we would need seven files: palyer_1.json.php, palyer_2.json.php, player_3.json.php, etc.,.
Other Small Changes
- The create key in the table definition file is no longer required.
- The updating event now fires correctly.
Try it
Impel.inTouch is used by the forthcoming HTML5 Javascript ORM, Impel, but you can use it separately without any trouble. It is free to use and modify for personal or commercial purposes, so have at it.
API documentation
Impel.inTouch-source.js
Impel.inTouch.js - packed
You'll also need a copy of MooTools
Oh, and feedback is always welcome. At some point soon, I'll enable comments on this blog, but until then contact me here