Home Javascript two async methods at once
Reply: 0

Javascript two async methods at once

user1616 Published in April 25, 2018, 12:27 pm

This question already has an answer here:

  • How does promise make code asynchronous? 1 answer
  • Are JavaScript Promise asynchronous? 1 answer

I am trying to simulate two asynchronous methods but am failing to figure out the concept behind it. I have this plunker where I am trying to calculate fibonacci number and at the same time do some additional work. The code required for the issue is located in src/app.ts The actions are as follows:

  1. I click Get Fibonacci
  2. Immediately after I click Click while Fibonacci loads a few times

I want the result to be like

loading status status status finished

but I get

loading finished status status status

because my promise locks UI and I am failing to understand how to make it not do so. If not looking at the example, the code for the promise looks like this:

var promise = new Promise((resolve, reject) =>
promise.then(result => {
  this.result = result;
  this.status += " finished";

What am I missing?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.309705 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO