When initializing a hoodie instance, an optional URL
can be passed. That's the URL of a hoodie backend.
If no URL passed it defaults to the current domain
with an api subdomain.
// init a new hoodie instance
hoodie = new Hoodie
remove trailing slash(es)
init core modules
online (read-only)
checkConnectionInterval (read-only)
use this method to send requests to the hoodie backend.
promise = hoodie.request('GET', '/user_database/doc_id')
if a relative path passed, prefix with @baseUrl
the checkConnection method is used, well, to check if
the hoodie backend is reachable at baseUrl or not.
Check Connection is automatically called on startup
and then each 30 seconds. If it fails, it
hoodie.online = falseoffline eventcheckConnectionInterval = 3000when connection can be reestablished, it
hoodie.online = trueonline eventcheckConnectionInterval = 30000generic method to open a store. Used by
... and more
hoodie.open("somestorename").findAll()
helper to generate unique ids.
default uuid length to 7
uuids consist of numbers and lowercase letters only. We stick to lowercase letters to prevent confusion and to prevent issues with CouchDB, e.g. database names do wonly allow for lowercase letters.
eehmm, yeah.
returns a defer object for custom promise handlings. Promises are heavely used throughout the code of hoodie. We currently borrow jQuery's implementation: http://api.jquery.com/category/deferred-object/
defer = hoodie.defer()
if (good) {
defer.resolve('good.')
} else {
defer.reject('not good.')
}
return defer.promise()
returns true if passed object is a promise (but not a deferred), otherwise false.
if a hoodie instance is not needed anymore, it can
be disposed using this method. A dispose event
gets triggered that the modules react on.
You can either extend the Hoodie class, or a hoodie instance dooring runtime
Hoodie.extend('magic1', funcion(hoodie) { /* ... */ })
hoodie = new Hoodie
hoodie.extend('magic2', function(hoodie) { /* ... */ })
hoodie.magic1.doSomething()
hoodie.magic2.doSomethingElse()
expose Hoodie to module loaders. Based on jQuery's implementation.
Expose Hoodie as module.exports in loaders that implement the Node module pattern (including browserify). Do not create the global, since the user will be storing it themselves locally, and globals are frowned upon in the Node module world.
Register as a named AMD module, since Hoodie can be concatenated with other files that may use define, but not via a proper concatenation script that understands anonymous AMD modules. A named AMD is safest and most robust way to register. Lowercase hoodie is used because AMD module names are derived from file names, and Hoodie is normally delivered in a lowercase file name.
Hoodie
the door to world domination (apps)