美文网首页
2019-03-20 关于FSA--- Flux Standar

2019-03-20 关于FSA--- Flux Standar

作者: KingAmo | 来源:发表于2019-03-20 10:47 被阅读0次

什么是FSA?

FSA 是 Flux Standard Action 的缩写,是一个编写 action 的标准 (当然redux中也可以用)。
GitHub 介绍:flux-standard-action

符合FSA标准的action必须

  • 必须是一个JavaScript对象
  • 必须有一个 type 属性

还可以(optional

  • 可以有一个 error 属性
  • 可以有一个 payload 属性
  • 可以有一个 meta 属性

符合FSA标准的action不能有除了type, payload, error, meta 以外的属性。

type

type 必须是 String 类型的常量。

payload

The optional payload property MAY be any type of value. It represents the payload of the action. Any information about the action that is not the type or status of the action should be part of the payload field.

By convention, if error is true, the payload SHOULD be an error object. This is akin to rejecting a promise with an error object.

error

The optional error property MAY be set to true if the action represents an error.

An action whose error is true is analogous to a rejected Promise. By convention, the payload SHOULD be an error object.

If error has any other value besides true, including undefined and null, the action MUST NOT be interpreted as an error.

meta

The optional meta property MAY be any type of value. It is intended for any extra information that is not part of the payload.

Library

  • redux-actions -一系列的工具帮助你在 Redux 中创建和处理 FSA actions.
  • redux-promise - Redux promise middleware that supports FSA actions.

这两个库通常结合起来使用

相关文章

网友评论

      本文标题:2019-03-20 关于FSA--- Flux Standar

      本文链接:https://www.haomeiwen.com/subject/hxzamqtx.html