angular

Using Async Await in Angular computed signal


Is it possible to use async await inside of an Angular computed signal?

I have tried to play with that but so far i couldn't make it work correctrly (fetching the value, manipulate the value and returning a raw value to the signal computed result and not a promise)


Solution

  • You should/can not use async/await inside of computed signal.

    You can run async code independently and then set/mutate/update signal or you can use effect function which accepts async functions.

    I would recommend reading more about signals and effects here: https://www.angulararchitects.io/aktuelles/angular-signals/.