Introduction
In this blog post, I would like to discuss how signal and HttpClient can retrieve data in Angular. In my observation, I fo...
For further actions, you may consider blocking this person and/or reporting abuse
Hi Connie Leung,
Your tips are very useful
Thanks for sharing
Thank you so much
Very simple and clear explanation. Thanks @railsstudent 🙏
Thank you so much for your support
Good overview, well done!
Connie, what do you say about not using HttpClient at all but a fetch with async/await and adding some features around that?
I will continue to use HttpClient.get because there are some use cases that RxJS is good at.
RxJS also has lastValueFrom to convert Observable to Promise. For Angular developers who want to deal with Promises, they can check out firstValueFrom and lastValueFrom in the RxJS Doc.
By the way, I love your ng news updates and youtube. It helps me keep up-to-date to the latest Angular news and Ngrx Signal Store
Thanks, great article. I noticed that in the first case (Signal + HttpClient + AsyncPipe) the pokemon does not update on changing pokemonId, others do.
So what do you think about wrapping it in computed like this?
pokemon$ = computed(() => this.getPokemon(this.pokemonId()));and of course
@if (pokemon$() | async; as pokemon) {<app-pokemon [pokemon]="pokemon" />
}
Thanks :)
I will use toSignal to convert pokemon$ to Signal and display the signal in the HTML template.
Then, we either use @if/async or @let syntax to pass the pokemon to the component to render.