Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Advice for overriding fetch() with custom data collection function?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Lance Vick  
View profile   Translate to Translated (View Original)
 More options Aug 20 2012, 5:46 pm
From: Lance Vick <la...@lrvick.net>
Date: Mon, 20 Aug 2012 14:46:58 -0700 (PDT)
Local: Mon, Aug 20 2012 5:46 pm
Subject: Advice for overriding fetch() with custom data collection function?

Hey all. So I am trying to integrate a data collection library with
backbone. My assumption would be to override the 'fetch' function and use
it to initiate my data collection library as needed.

My data collection library polls data from remote JSON-P APIs and then
passes each collected item to my supplied callback. I have a HyveItem model
prepared to handle the output so I would assume I just need to call create,
however for some reason even with an explicit bind, 'this' in this.create
appears to be the Window object, which obviously breaks things.

Any advice?

var HyveItems = Backbone.Collection.extend(
        { model: HyveItem
        , localStorage: new Backbone.LocalStorage("HyveItems")
        , max_items: 100
        , initialize: function(opts){
            this.on('add', this.trim)
          }
        , trim: function(){ if(this.length > this.max_items) this.shift() }
        , fetch: function(options){
            this.reset()

            var callback = _.bind(this.create, this)

            // hyve collects data from many different json-p feeds.
            // create is used as a callback here for each returned item
            hyve.friends.stream( callback, options )

          }
        , pause: function() {
            hyve.stop()
          }
        }
    );


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »