Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 21:02
    bmomberger-bitovi synchronize #5451
  • 21:02

    bmomberger-bitovi on update-deps

    Update can-control to latest (compare)

  • Jan 21 14:21
    frank-dspeed commented #5460
  • Jan 21 14:13
    frank-dspeed commented #5460
  • Jan 21 14:12
    frank-dspeed commented #5460
  • Jan 21 14:10
    frank-dspeed commented #5460
  • Jan 21 13:37
    jvkdev starred canjs/canjs
  • Jan 21 13:36
    justinbmeyer commented #5460
  • Jan 21 06:45
    frank-dspeed commented #5460
  • Jan 21 06:42
    frank-dspeed edited #5460
  • Jan 21 06:41
    frank-dspeed opened #5460
  • Jan 20 21:58
    justinbmeyer commented #5459
  • Jan 20 07:49
    frank-dspeed opened #5459
  • Jan 19 16:39
    leoj3n commented #5107
  • Jan 19 16:37
    leoj3n commented #5107
  • Jan 19 16:32
    ThomasBrickerBK starred canjs/canjs
  • Jan 18 01:06
    greenkeeper[bot] commented #5422
  • Jan 18 01:06

    greenkeeper[bot] on @feathersjs

    chore(package): update @feather… (compare)

  • Jan 18 00:48

    greenkeeper[bot] on @octokit

    (compare)

  • Jan 18 00:46

    greenkeeper[bot] on @octokit

    chore(package): update @octokit… (compare)

opolyo01
@opolyo01
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
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
unfortunately yes
dylanrtt
@dylanrtt
what does the future of validations look like?
Patrick Clancy
@patrickclancy
@dylanrtt I found this. bitovi/canjs#1111
Matthew Phillips
@matthewp
yeah i think it's one of those things that no one has figured out yet
opolyo01
@opolyo01
@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
@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
opolyo01
@opolyo01
does this look right?
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 ];
}
else{
var dfd = $.Deferred();
dfd.promise(promiseStore[ key ]);
dfd.resolve( JSON.parse(promiseStore[ key ].responseText) );
return promiseStore[ key ];
}
dylanrtt
@dylanrtt

@opolyo01 you can probably do it exactly like the QuickCache example. just copy the makeFindAll function out so it's independent and call it like this

var TodoModel = can.Model.extend({
  findTodos: makeCacheable(function(){
    return $.ajax(/*params*/);
  })
}, {});

That should allow you to make any request function cacheable. You can still use it with the standard find methods like this:

var QuickCacheModel = can.Model.extend({
  makeFindAll: makeCacheable
}, {});
Curtis Cummings
@ccummings
I’m trying to create a nested Map that can have children that are the same type. Here’s a jsbin of the setup: http://jsbin.com/peyesififu/1/edit
Depending on what’s defined first I can either have the list be the right type or the map, but not both
dylanrtt
@dylanrtt
@ccummings I had this issue before. Basically one of them needs to be defined before you can reference it in the other. I solved this by modifying the define block of one prototype after declaring both http://jsbin.com/yosakoqozo/1/edit?html,js,console
Curtis Cummings
@ccummings
My brain must be fried. I can also modify the static Map parameter of the list after both are defined
both ways will work. Thanks!
Ilya Fadeev
@ilyavf
hey guys, how can i listen to a list element's property change?
var Row = can.Map({
    define: {
        isChecked: {
            type: 'boolean'
        }
    }
});
var VM = can.Map({
    define: {
        items: {
            Type: Row.List
        }
    }
});
can.Component.extend({
    events: {
        '{scope.items. ??? .isChecked} change': function(){ 
            console.log('item is checked'); 
        }
    }
});
opolyo01
@opolyo01
Hey guys, I am facing an issue where I have 3 Deferreds, and only first one resolves. Other two getting rejected, even though they are all the same deferreds. Any idea?
basically, it is 3 $.ajax deferreds that should have ".then" to have a callback executed, but only first then getting executed. If I do from chrome console it works fine
David Luecke
@daffl
What's the reason for the other Deferreds to get rejected?
Justin Meyer
@justinbmeyer
@ilyavf why are you doing this?
Ilya Fadeev
@ilyavf
@justinbmeyer I have a grid with rows and i need to maintain a hash map of selected rows
opolyo01
@opolyo01
@daffl no idea why is getting reject when I call this from my components
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
                });

            }
promiseStore[ key ].then(function(resp){
console.log(resp);
});

return promiseStore[ key ];
Justin Meyer
@justinbmeyer
@ilyavf can you do this w/ a compute instead
opolyo01
@opolyo01
3 components will call this model and I get 3 console.log printed
Justin Meyer
@justinbmeyer
@opolyo01 can you put that in a ```
@patrickclancy regarding model validation ... I would not use our validation plugin
it's probably more simple to use the define plugin
Patrick Clancy
@patrickclancy
@justinbmeyer how would you suggest using the define plugin?
Ilya Fadeev
@ilyavf
@justinbmeyer Like, have a compute property which iterates through my list of items and reads item's property I am interested to listen to?
Patrick Clancy
@patrickclancy
with getters and setters
Justin Meyer
@justinbmeyer
@patrickclancy something like:
define: {
  isNameValid: {
    get: function(){
      return !!this.attr("name")
    }
  }
}
and you could create "mixins" that help set this up
define: validators({}, validateExists("name"))
opolyo01
@opolyo01
@daffl So yeah, promiseStore[ key ].then will be rejected within my components scope, but no while I am in the model. So I wonder would could reject the promise? I know I don't do .reject anywhere
Justin Meyer
@justinbmeyer
@ilyavf yes
do this in the view model
Patrick Clancy
@patrickclancy
@justinbmeyer interesting… I like using the define plugin… everything else is there. I’d need to roll in the check all type functionality that model.errors() provides. But that wouldn’t be hard
Justin Meyer
@justinbmeyer
yeah, the check functionality
is the one thing that this is missing
but in my opinion, having observability
is more important
oh, you mean check all