isPending status as event in script?


is there any possibility to use the state isPending from template in the viewmodel as event to fire some sort of other pluign ?



I think you need to explain a bit more what you mean.

Something like

<child-plugin {prop}="promise.isPending">



thats look interesting … how do i react in javascript code on this ?

I mean something like

can.Component({ events: { "isPending": function(){ // do something special ... } } })

@Maj0rrush I’m assuming you want to observe when the promise is resolved. If you have something in your view model like this (copied from your other thread):

portals: {
  get: function(lastSetValue, resolve) {

You could observe the resolution of portals in the events object of the same component like this:

events: {
  '{viewModel} portals': function(vm, ev, newVal, oldVal) {
    // portals has resolved


i would observer if it is isPending or resolved or error … but i must do this in javascript to fire some sort of jquery plugin …

with your example i know when its resolved but how know i when it is isPending ?

I don’t believe you have the same flexibility for observing it as you do in the template. However, it will be pending as long as the request has fired and is not resolved. In my example, the request fires when the property is bound. If the property is bound immediately in the view, you can assume it is pending until it is resolved.

You may simply have to attach your own then() to the promise to observe it manually.

Ok i try this. Thank You !