Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unclear usage of effect to retrieve data in async way #54047

Closed
@TarsisDragomir

Description

@TarsisDragomir

Describe the problem that you experienced

I'm really enthusiastic about the new features in angular 17, but I'm unsure on how to use the new effects. It seems the new way to make an application reactive (without the need for rxjs mostly), but if I look at the official angular.dev explanation on effect it states "Effects are rarely needed in most application code" which feels a bit strange. Does this mean angular prefers us to stick with rxjs streams for reactivity and fetching data?
On the other hand I find plenty of other examples on blogs/X/... where effect are used to initiate retrieving data and setting other signals their value (since it's an async process writing to signal just works without errors there). Even initiatives like computedAsync are based on that pattern. If we work like that, are we ignoring angular best practices? Or is this allowed/the future of reactivity in angular?

Enter the URL of the topic with the problem

https://angular.dev/guide/signals

Describe what you were looking for in the documentation

Probably I overlooked, but on angular.dev I find no example at all on how to trigger an http get call to retrieve data and how to store that data (in signals).

Describe the actions that led you to experience the problem

Upgrading and adapting to angular 17, but became confused by official statements on angular.dev and examples elsewhere (because of the lack of examples on angular.dev itself).

Describe what you want to experience that would fix the problem

A clear statement from the angular team on this topic :)

Provide any additional information here in as much as detail as you can

I've setup a stackblitz to show 3 different approaches I see now, probably we can find even more variations, but really wondering what to choose/which is the 'default angular way'...
https://stackblitz.com/edit/stackblitz-starters-bg7wyc?file=src%2Fmain.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimecore: reactivityWork related to fine-grained reactivity in the core frameworkcross-cutting: signals

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions