Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Any advice on using findall/findOne the "right" way...

$
0
0
1.  You should be calling the base model and models methods with either super or  can.Model.models( data.nested.results )


2.  I'm not sure what you mean.  Task.findAll({},success) will call success back.  You might mean that it doesn't pass it to your overwritten findAll. But this makes a lot of sense.  It makes the signature for findAll:

findAll(params) -> deferred(rawArray)

instead of what it need to be before (having success being called with the the model instances).

3. I'm not sure what you mean again.  
notice that the functions I chained cause my raw data to be converted to models
chaining?  Do you mean something like deferred.pipe?  cause? Nothing you do "causes" the model conversion, can.Model does that itself.

Caching of requests is done easily. 

var defMap = {};
findAll: function(params){
  if( !defMap[ JSON.strinify(params) ]){
     defMap[ JSON.strinify(params) ] = $.get( .... )
  }
  return  defMap[ JSON.strinify(params) ]
}


 Also, you can use makeFindAll to implement more complex caching functionality.




Viewing all articles
Browse latest Browse all 3491

Trending Articles