A talk I gave at Codemotion Madrid on November 21 of 2014 about the JavaScript application framework hood.ie
I give a brief introduction to the pain points of "online-only" applications, how to use hoodie and then talk a bit about the architecture of the framework.
After that I go into detail about its main features, user management, data storage, events and synchronization.
For those of you who are interested in developing offline-first, you should check out the hoodie website at http://hood.ie.
5. PAIN POINTS
Every action depends on a connection
Apps save all user-specific data online
No fallback solution when connection fails
6. PAIN POINTS
Every action depends on a connection
We need offline first solutions
Apps save all user-specific data online
No fallback solution when connection fails
7. „We can’t keep building apps with
the desktop mindset of permanent,
fast connectivity, where a temporary
disconnection or slow service is
regarded as a problem and
communicated as an error.“
— Jan Lehnardt, hood.ie team
8. We used HTML5 features to make the
site available offline. Users can look
up full information about conferences
they're attending even if they have no
data connection.
— Jake Archibald, Lanyrd’s lead engineer
21. ADD A NEW OBJECT
var type = 'goldnugget';
var attributes = { category: 'raw',
value: '$1200' };
hoodie.store.add(type, attributes)
.done(function (goldnugget) { … });
ALL DATA IS PRIVATE BY DEFAULT, NOT PUBLIC!
22. App
digs a gold nugget
hoodie store API
Hoodie’s API decouples client/server.
It can get interrupted or stop at any
stage without breaking.
couchDB
localStorage NoSQL storage
23. FINDING ALL OBJECTS
var type = 'goldnugget';
hoodie.store.findAll(type)
.done(function (goldnuggets) { … });
OTHER FUNCTIONS
update(type, id, update), find(type, id),
remove(type, id), removeAll(type)
26. IMPLEMENTING EVENTS
hoodie.account.on('signin', function (user) {…});
USER HAS SIGNED IN,
ALSO FIRES THE „AUTHENTICATED“ EVENT
hoodie.store.on('add:bullet', function (bullet) {…});
WITH : WE CAN LISTEN TO CHANGES FOR A SPECIFIC OBJECT TYPE
31. IMPLEMENTATION
hoodie.remote.on('add:peng', function (peng) {…});
GETS CALLED WHEN AN EVENT IS TRIGGERED REMOTELY
hoodie.remote.on('change', function (whatever) {…});
GETS CALLED FOR ANY OF THE EVENTS: ADD, UPDATE, REMOVE…
33. Every action depends on a connection
Apps save all user-specific data online
No fallback solution when connection fails
34. Actions can be performed without being connected
Every action depends on a connection
Apps save all user-specific data offline
Apps save all user-specific data online
Falls back to localStorage when connection fails
No fallback solution when connection fails