# isPending status as event in script?

**URL:** <https://forums.bitovi.com/t/ispending-status-as-event-in-script/247>\
**Category:** CanJS\
**Created:** [May 1, 2016, 5:40pm UTC](https://forums.bitovi.com/t/ispending-status-as-event-in-script/247 "2016-05-01T17:40:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maj0rrush](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/maj0rrush/32/117_2.png) [@Maj0rrush](https://forums.bitovi.com/u/Maj0rrush)\
**Post date:** [May 1, 2016, 5:40pm UTC](https://forums.bitovi.com/t/ispending-status-as-event-in-script/247/1 "2016-05-01T17:40:04Z")

</div>

Hi,

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

Greetz,

Markus

---

<div class="post-metadata">

**Author:** ![justinbmeyer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/justinbmeyer/32/179_2.png) [@justinbmeyer](https://forums.bitovi.com/u/justinbmeyer)\
**Post date:** [May 1, 2016, 7:15pm UTC](https://forums.bitovi.com/t/ispending-status-as-event-in-script/247/2 "2016-05-01T19:15:46Z")

</div>

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

Something like

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

```

?

---

<div class="post-metadata">

**Author:** ![Maj0rrush](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/maj0rrush/32/117_2.png) [@Maj0rrush](https://forums.bitovi.com/u/Maj0rrush)\
**Post date:** [May 1, 2016, 8:08pm UTC](https://forums.bitovi.com/t/ispending-status-as-event-in-script/247/3 "2016-05-01T20:08:37Z")

</div>

Hi,

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

I mean something like

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

---

<div class="post-metadata">

**Author:** ![DylanRoss](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/dylanross/32/71_2.png) [@DylanRoss](https://forums.bitovi.com/u/DylanRoss)\
**Post date:** [May 5, 2016, 9:02pm UTC](https://forums.bitovi.com/t/ispending-status-as-event-in-script/247/4 "2016-05-05T21:02:09Z")

</div>

@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):

```auto
portals: {
  get: function(lastSetValue, resolve) {
    Portal.findAll({}).then(resolve);
  }
}

```

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

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

```

---

<div class="post-metadata">

**Author:** ![Maj0rrush](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/maj0rrush/32/117_2.png) [@Maj0rrush](https://forums.bitovi.com/u/Maj0rrush)\
**Post date:** [May 6, 2016, 11:27am UTC](https://forums.bitovi.com/t/ispending-status-as-event-in-script/247/5 "2016-05-06T11:27:10Z")

</div>

hi,

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 ?

---

<div class="post-metadata">

**Author:** ![DylanRoss](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/dylanross/32/71_2.png) [@DylanRoss](https://forums.bitovi.com/u/DylanRoss)\
**Post date:** [May 6, 2016, 6:02pm UTC](https://forums.bitovi.com/t/ispending-status-as-event-in-script/247/6 "2016-05-06T18:02:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Maj0rrush](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/maj0rrush/32/117_2.png) [@Maj0rrush](https://forums.bitovi.com/u/Maj0rrush)\
**Post date:** [May 6, 2016, 7:59pm UTC](https://forums.bitovi.com/t/ispending-status-as-event-in-script/247/7 "2016-05-06T19:59:51Z")

</div>

Ok i try this. Thank You !
