Open pm5 opened 6 years ago
Action 命名問題 Action 能直接從名字看出它是 synchronous 的或是會 asynchronously request backend 的,會比較方便。可能要討論一組動詞來區分兩種 action,例如 update 開頭的都是 synchronous、(create|delete|add|remove|move) 開頭的都是 asynchronous。這要大概整理一下會有哪些 action 再來列表會比較完整。
卡西:我理想的 actions 全部都是 async actions ,這樣才方便組合。傳回的也不該是 Promise ,而是看狀況成為 Promise<ObjectData> 或 Promise<CardData> 。修改 state 都是 side-effect 。但既然整個生態圈沒有往這個方向發展,我怎樣都 Ok 。
Promise<ObjectData>
Promise<CardData>
這也跟 state management 有關。正好最近有人整理了現況,附 code example。
@caasi 的 code example https://gist.github.com/caasi/a28b35c210591d9ff8a68d791469c493
Action 命名問題 Action 能直接從名字看出它是 synchronous 的或是會 asynchronously request backend 的,會比較方便。可能要討論一組動詞來區分兩種 action,例如 update 開頭的都是 synchronous、(create|delete|add|remove|move) 開頭的都是 asynchronous。這要大概整理一下會有哪些 action 再來列表會比較完整。
卡西:我理想的 actions 全部都是 async actions ,這樣才方便組合。傳回的也不該是 Promise ,而是看狀況成為
Promise<ObjectData>
或Promise<CardData>
。修改 state 都是 side-effect 。但既然整個生態圈沒有往這個方向發展,我怎樣都 Ok 。