Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 Return an already resolved promise

I'd like to create and return an already resolved (fake if you prefer) Promise in angular2. In angularjs you would do something like : return $q.defer().promise

I was thinking about doing : return new Observable<any>.toPromise() However I am not sure if that's the right way to do it.

like image 658
Scipion Avatar asked Dec 15 '22 04:12

Scipion


1 Answers

Promise.resolve('someValue');

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve

like image 167
Günter Zöchbauer Avatar answered Dec 18 '22 11:12

Günter Zöchbauer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!