How to do a ngIf based on a promise in angular?

Issue I’m trying to do a ngIf where the result is depending on a promise. The template <div> <select [(ngModel)]=”carValue” name=”carName”> <option value=”renault”>Renault</option> <option value=”bmw”>Bmw</option> </select> <p *ngIf=”isDisplayed()”>Good choice!</p> </div> So far, the function isDisplayed is isDisplayed() { return this.carValue

Continue reading

Deferred that extends Promise

Issue How to implement a Deferred promise that extends Promise? It’s important to extend Promise for type-safe usage where a typical Promise is expected. Following implementation export class Deferred<T> extends Promise<T> { public _resolveSelf; public _rejectSelf; constructor() { super( (resolve,

Continue reading

firebaseAuth GoogleAuthProvider() signInWithRedirect

Issue I’ve a authentication Google with redirect in my app, and I would like just redirect when authentication is completely finished. But the promise is not working function loginGoogle() { var provider = new firebase.auth.GoogleAuthProvider(); firebase.auth().signInWithRedirect(provider); firebase.auth().getRedirectResult().then(function (result) { //

Continue reading

Queuing Promises (ES6)

Issue I’m writing a NodeJS service that requests data from APIs. Under load, I don’t want to hammer the API with potentially hundreds of simultaneous requests, so I am trying to queue up the requests so they are executed one-by-one

Continue reading

Use async await with Array.map

Issue Given the following code: var arr = [1,2,3,4,5]; var results: number[] = await arr.map(async (item): Promise<number> => { await callAsynchronousOperation(item); return item + 1; }); which produces the following error: TS2322: Type ‘Promise<number>[]’ is not assignable to type ‘number[]’.

Continue reading

Use async await with Array.map

Issue Given the following code: var arr = [1,2,3,4,5]; var results: number[] = await arr.map(async (item): Promise<number> => { await callAsynchronousOperation(item); return item + 1; }); which produces the following error: TS2322: Type ‘Promise<number>[]’ is not assignable to type ‘number[]’.

Continue reading