找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 471|回复: 0

Create a container in your GTM account

[复制链接]

1

主题

0

回帖

5

积分

新手上路

积分
5
发表于 2023-12-4 11:33:51 | 显示全部楼层 |阅读模式
These functions are responsible for the state of the application and only with their help should we change the state of the application never directly. The reducer checks the action type and decides what to do with the state based on the logic implemented in the function. For example when we want to update user data we can call the dispatch method with a given payload with the example name UPDATEUSER. When the action reaches the reducer it will check its type and then based on the type it will find the appropriate part of the code to be executed and return a new copy of the state along with the completed user data. Effect Effects powered by RxJS give us the ability to create side effects.

Effects are dedicated places where we can delegate various activities such as retrieving data from the REST API which the components should not actually know about. Effects isolate side effects from components allowing them to maintain very clean code. For example when we call the dispatch method with the GETUSER action the action Email Marketing List will be caught by its type and within the effect communication with the REST API via the service takes place. When data from the REST API is retrieved the effect will return a new action for example an action of the GETUSERSUCCESS or GETUSERFAILED type.



Then based on these actions we can for example display an appropriate error message to the user or handle it in any other way on the application side. Selector Selectors are pure functions that we use when we want to download some data from the store. Pure function means that the same result will always be returned for the same arguments. We can use selectors in components to listen for changes in the store  all you need to do is subscribe to them once.

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|DiscuzX

GMT+8, 2024-10-19 11:54 , Processed in 0.087505 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表