These are chat archives for canjs/canjs

10th
Jun 2015
opolyo01
@opolyo01
Jun 10 2015 01:43
Found an issue, but trying to figure out the best way to resolve deferred without making separate AJAX calls
find: function ( type, params ) {
var key;
key = JSON.stringify( params );
if ( ! promiseStore [ key ] ) {
promiseStore[ key ] = $.ajax({
url: can.sub(steal.config('API')[ type ], params, true),
data: params,
type: 'GET',
dataType: 'json',
// work around the ajax bug in chrome
cache: false
});
        }
        return promiseStore[ key ];
    },
I call this find method in bunch of components, and goal is to make a single Ajax request, and get the rest from Cache. However, the first then is getting resolved, but other then calls already being resolved
Is there a good pattern to solve this issue? I am thinking to add else wrap it in the separate Deferred
Patrick Clancy
@patrickclancy
Jun 10 2015 13:27
I’m starting to add validation to a can v2.3-pre project. Is the validation plugin still the perferred way to define model validation?
Matthew Phillips
@matthewp
Jun 10 2015 13:27
unfortunately yes
dylanrtt
@dylanrtt
Jun 10 2015 13:29
what does the future of validations look like?
Patrick Clancy
@patrickclancy
Jun 10 2015 13:42
@dylanrtt I found this. bitovi/canjs#1111
Matthew Phillips
@matthewp
Jun 10 2015 13:43
yeah i think it's one of those things that no one has figured out yet
opolyo01
@opolyo01
Jun 10 2015 22:59
@akagomez So to make caching work, do I need to override every method with "make" prefix? Another question is how to actually get this 'findAllData' deferred to work in case if I actually not relying on resources, but making an actual $.ajax request
dylanrtt
@dylanrtt
Jun 10 2015 23:27
@opolyo01 I don't think the make prefix works with anything other than the standard functions, so if you have a lot of custom methods on your model, you might have to implement something like what you have above