- Architecting Angular Applications with Redux,RxJS,and NgRx
- Christoffer Noring
- 239字
- 2021-08-27 19:56:18
Action – capture the intent
An action is something as simple as an intent with accompanying data, that is, a message. How does an action come about though? An action comes about when a user interacts with a UI. The user may select a specific item in a list or a press a button with the intention of submitting a form. Submitting the form should, in turn, lead to a product being created.
Let's look at two different actions:
- Selecting an item in a list, here we are interested in saving the index of our selected item
- Saving a todo to a todo list
An action is represented by an object. The object has two properties of interest:
- The type: This is a unique string that tells us the intention of the action, for example, SELECT_ITEM
- The data: This is the data we mean to persist, for example, the numerical index of a selected item
Given our first example action, a code representation of that action would look like the following:
{
type: 'SELECT_ITEM',
data: 3 // selected index
}
OK, so we have prepared our action, which we can also think of as a message. We want the message to be sent so that the selected item is highlighted in the UI. As this is a undirectional flow, we need to follow a charted course and pass our message over to the next party, which is the dispatcher.
- 黑客攻防實戰技術完全手冊:掃描、嗅探、入侵與防御
- 解析QUIC/HTTP3:未來互聯網的基石
- Mastering Machine Learning for Penetration Testing
- 物聯網(IoT)基礎:網絡技術+協議+用例
- Oracle SOA Suite 11g Performance Tuning Cookbook
- 計算機網絡與數據通信
- Go Web Scraping Quick Start Guide
- 區塊鏈輕松上手:原理、源碼、搭建與應用
- 網管員必讀:網絡管理(第2版)
- 面向5G-Advanced的關鍵技術
- 計算機網絡技術及應用
- Master Apache JMeter:From Load Testing to DevOps
- Getting Started with Memcached
- 轉化:提升網站流量和轉化率的技巧
- 全聯網標識服務