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:
- I click Get Fibonacci
- 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) =>
resolve(this.fibonacci(num));
);
promise.then(result => {
this.result = result;
this.status += " finished";
});
What am I missing?