alekseykulikov / backbone-offline

[Deprecated] Allows your Backbone.js app to work offline
MIT License
720 stars 56 forks source link

Demo app? #5

Closed paulirish closed 12 years ago

paulirish commented 12 years ago

It'd be great to see this in action

alekseykulikov commented 12 years ago

My pleasure to see you here. This library was extracted from my project Saveidea and you can try the demo: https://saveideanow.com/demo_app

benbest86 commented 12 years ago

I think the request was more for a demo app with source code that shows the usage. Saveidea is a great demo app but as far as I can tell the source code is not public and the js is minified on the site and not readable.

I would also love to see a demo. I'm hoping to put together something extremely simple and will post a link to the code if I do.

alekseykulikov commented 12 years ago

I have a very simple solution, and can push it soon. At first I should prepare it for opening. Stay tuned.

benbest86 commented 12 years ago

Great! That would be much appreciated! Thanks!

On Mon, May 14, 2012 at 12:54 PM, Aleksey Kulikov < reply@reply.github.com

wrote:

I have a very simple solution, and can push it soon. At first I should prepare it for opening. Stay tuned.


Reply to this email directly or view it on GitHub: https://github.com/Ask11/backbone.offline/issues/5#issuecomment-5689327

buddye commented 12 years ago

This worked for me. In the todos example from https://github.com/addyosmani/todomvc/blob/master/architecture-examples/backbone/js/todos.js

In todos.js, comment out line 51:

//    localStorage: new Store("todos-backbone"),

and then add:

initialize: function() {
            return this.storage = new Offline.Storage('todos-backbone', this);
},

line 180, add/replace

Todos.url = 'api/todos';
Todos.fetch();

'/api/todos' being the REST handler

I'm using this for a proof of concept for using Backbone on a mobile app, so far so good. My .url atm though being on a local server: Todos.url = 'http://api.dev/todos'; CORS not an issue when browsing via file, I'm using Apache Cordova, so far it's working out.

I need to check out the data syncing algorithm though. Browsing via file, on refresh it seems to immediately sync all, but browsing via server, it doesn't sync changes on refresh.

EDIT nevermind, syncing works fine, was CORS, temp work around on REST handler (I'm using Rails), from ( http://www.codeodor.com/index.cfm/2011/7/26/Responding-to-the-OPTIONS-HTTP-method-request-in-Rails-Getting-around-the-Same-Origin-Policy/3387 ):

headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Request-Method'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS, DELETE, PUT'
headers['Access-Control-Max-Age'] = '1000'
headers['Access-Control-Allow-Headers'] = '*,x-requested-with, content-type'
alekseykulikov commented 12 years ago

Thanks @EthanEtienne for your experience, nice idea! For auto-sync (without push() and refresh page) you can use option autoPush: true

@storage = new Offline.Storage('dreams', this, autoPush: true)
abuisman commented 12 years ago

I think some demonstration code would be great too, the examples in the readme are broken, or at least not clear, or both. Please explain the pattern of how you intended things to work.

alekseykulikov commented 12 years ago

Sure. Sorry that I have not done it before. I'm too busy now, but I'm going to pull example at the next weekend.

alekseykulikov commented 12 years ago

Hi guys. I've added an open source example Dreamer. It very simple web-application for your dreams. Also added some information to Readme. I hope it will enough for a start.

paulirish commented 12 years ago

awesome work. thanks much for the app!

On Tue, Jul 10, 2012 at 4:30 AM, Aleksey Kulikov < reply@reply.github.com

wrote:

Hi guys. I've added an open source example Dreamer. It very simple web-application for your dreams. Also added some information to Readme. I hope it will enough for a start.


Reply to this email directly or view it on GitHub: https://github.com/Ask11/backbone.offline/issues/5#issuecomment-6872918

alekseykulikov commented 12 years ago

You're welcome!