timestamp: "Thu Mar 10 2016 01:11:12 GMT-0800 (PST)"
})
console.log(
"Length of colors array after ADD_COLOR",
store.getState().colors.length
)
//
在
ADD_COLOR
之后,颜色数组的长度是
4
console.log(
"Color rating before RATE_COLOR",
store.getState().colors[3].rating
)
//
在
RATE_COLOR
之前,颜色评分值是
0
store.dispatch({
type: "RATE_COLOR",
id: "2222e1p5-3abl-0p523-30e4-8001l8yf2222",
rating: 5
})
console.log(
"Color rating after RATE_COLOR",
store.getState().colors[3].rating
)
//
在
RATE_COLOR
之后,颜色评分值是
5
这里我们创建了一个
Store
,并分发了一个添加新颜色的
Action
,随后的
Action
是用来
修改颜色评分的。控制台输出信息向我们展示了分发
Action ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.