vAhy_The
vAhy_The

Reputation: 628

Vue.js How detect if component/page have complete all async calls ??

i have question there is some way, how to detect if page was rendered. I mean after all async calls. Is there some method isfinalyrendered ??

Thx

Upvotes: 0

Views: 738

Answers (1)

Helping hand
Helping hand

Reputation: 2920

First of all, have a logic to count the number of async calls in your component. As due to particular condition they might be more in one case and lesser in another case.

Then you just have to pass a callback in your async function, which increases the counter on promise resolve/reject. When counter's value==totalAsyncCalls. Then you can call your isfinalyrendered method

var count = totalAsyncCalls
    callback = function () {
        count--;
        if (0==count){
          isfinalyrendered();
         }

        // do stuff
    };

Upvotes: 1

Related Questions