Created
June 29, 2011 22:13
-
-
Save mrjjwright/1055149 to your computer and use it in GitHub Desktop.
Connect to DNode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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