Skip to content

Instantly share code, notes, and snippets.

@mrjjwright
Created June 29, 2011 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrjjwright/1055149 to your computer and use it in GitHub Desktop.
Save mrjjwright/1055149 to your computer and use it in GitHub Desktop.
Connect to DNode
# The root namespace for your app
# Everything starts from here.
window.App =
start: ->
# Connect to DNode
DNode.connect (remote) ->
try
# Our remote db object
App.db = remote.db
# Store.js is a localStorage polyfill (https://github.com/marcuswestin/store.js)
App.cache = store
# Try to load the user from local storage
App.user = cache.get('user') ? {}
# A mini-pubsub module
# https://github.com/daniellmb/MinPubSub
App.publish = publish
App.subscribe = subscribe
# Init the rest of your app, such as your models, and collections here..
App.sampleCollection = new SampleCollection()
# Kick things off by fetching one of your collections
# This will use our custom Backbone.sync.
App.sampleCollection.fetch()
$(document).ready -> App.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment