If you’ve got the time: there’s also a slightly older long intro. with more technical background info.
1. Instantiating your Hoodie
Just one line of JS to get started with Hoodie.
2. User signup
Yes, that’s all. signOut, signIn and the other account management functions are similarly short and sweet.
3. Storing data
This will store a task in this new user’s store ()
As you can see, the documents you store need a type and some JSON data. Both are arbitrary and don’t need to be set up anywhere previously. Just pass Hoodie an object for your data, it will eat anything and save it as JSON.
The promises returned by Hoodie are a good place to deal with the UI immediately related to the action, such as disabling a submit button while data is sent, showing and hiding a loading spinner, displaying success and error messages and all that. However, the actual data that you’ve sent or retreived is best dealt with in a more decoupled manner, with database events:
4. Event listeners
The view should update whenever a task is added, so let’s listen to the data store directly for when that happens:
This way, you have nicely reactive views. Users can now add tasks on one device, and the new task will automatically appear on the running page on any other device they may be using simultaneously.
5. Loading data
Let’s load all of the user’s ‘task’ documents:
Find out more about sharing, making data public, listening to remote events and sending emails in the Hoodie Documentation