- Consult this README
- Read the Guides:
- Consult the API documentation
- Ask in the IRC Channel (#remotestorage on freenode)
- Open an issue for discussion, either in the relevant repository or the website repo for general discussion
127.0.0.1 local.dev
sudo node server/nodejs-example.js
add "remoteStorage-modules.js" (you can download it from http://remotestoragejs.com/build/0.7.0-head/remoteStorage-modules.js)
<script src="remoteStorage-modules.js"></script>
<div id="remotestorage-connect"></div>
remoteStorage.claimAccess('tasks', 'rw');
and after you have loaded all the modules you will be using, but still in your app's onload function,
remoteStorage.displayWidget('remotestorage-connect');
todos = remoteStorage.tasks.getPrivateList('todos');
todos.on('error', function(event) {
// you can set up this event handler, but currently it isn't used.
// will probably be in the future though.
});
todos.on('change', function(event) {
if(event.newValue && event.oldValue) {
console.log(event.path + " was updated")
} else if(event.newValue) {
console.log(event.path + " was created")
} else if(event.oldValue) {
console.log(event.path + " was deleted")
}
});
note that your change handler will be called with an object that has an 'origin' field, that comes with a value of 'tab', 'device', or 'cloud'
Note: maybe 'window' is a better term than 'tab' here, this sort of details is still subject to change in the final v0.7
returns an array of id's, which you can use to retrieve the actual objects.
returns an object from the list, or undefined if there is no object in the list with that id
sets the item with that id to that object (might trigger a 'change' event with origin 'tab').
creates a new todo item with that text, completed set to false, and a randomly generated id, which is returned by the function.
removes that item
marks that todo item as completed (you can see we really have a higher-level API here that understands that tasks are things that have a boolean 'completed' field)
returns true or false. this one is maybe a bit silly, you could also just get the object and read the obj.completed field. or maybe we should make obj.isCompleted(), inline with OO practice. Anyway, you get the idea. I hope that with this everybody can write apps very easily based on modules like this. For now i only included 'tasks', but once this works it should be easy to make first versions of other modules like 'documents', 'contacts', 'photos', 'stuff', 'music', etcetera. Pull requests welcome! :)