Explicit control over HTTP requests

83 views
Skip to first unread message

Mike Harley

unread,
Sep 13, 2012, 9:48:31 PM9/13/12
to batm...@googlegroups.com
With Backbone.js, you have to request data from the server explicitly in your router actions. (This is accomplished by calling fetch() on the collection.)

I'm looking for a way to get that level of control over server requests in Batman.js. To be more specific, what I'm looking to have (in pseudo-code):

Fetch Posts from /posts.json (posts) ->
  iterate over posts and do something with that

Some of my models (though not all) will be updated in real-time using Socket.IO. By default, when you call find, Batman is going to make an HTTP request for the data. This obviously works well in most situations, but when you introduce real-time updates (ensuring the cached model data never gets stale), it isn't ideal - it's just wasted bandwidth.

What would the best way to go about this be?

Dave Steinberg

unread,
Sep 14, 2012, 10:07:16 PM9/14/12
to batm...@googlegroups.com
Simple - don't call find() or load().  :)  Take a look in the archives for 'socket.io', there is at least one thread where I and others describe how we're doing this.  There is no explicit support but it's not hard to accomplish.

-- Dave

Maedi

unread,
May 1, 2013, 5:50:52 AM5/1/13
to batm...@googlegroups.com
Mike. Curious to how you did this in the end?

Kristian Plettenberg-Dussault

unread,
May 8, 2013, 5:38:42 PM5/8/13
to batm...@googlegroups.com
Take a look at https://github.com/zhubert/fancy_batman_app.  It may not be exactly what you're looking for but may give some ideas


On Thursday, September 13, 2012 9:48:31 PM UTC-4, Mike Harley wrote:
Reply all
Reply to author
Forward
0 new messages