Last active
August 29, 2015 14:26
-
-
Save Jazznight/77b762d73c16c854cf26 to your computer and use it in GitHub Desktop.
Revisions
-
cswleocsw revised this gist
Jul 30, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,7 +19,7 @@ export function getAllProduction () { 2. 將 ajax 的行為都定義在其他地方, actions 只作簡單定義 ,例如 ProductionActions.js export function getAllProduction (data) { return { type: GET_PRODUCTS data" data -
cswleocsw revised this gist
Jul 30, 2015 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ 1. 將 ajax 的行為都定義在 actions 裡,例如 ProductionActions.js export function getAllProduction () { @@ -37,5 +36,3 @@ $.ajax('xxx/productions, { } 流程:ajax -> ajax success callback -> action -> dispatch -
cswleocsw created this gist
Jul 30, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ 1. 將 ajax 的行為都定義在 actions 裡,例如 ProductionActions.js export function getAllProduction () { return (dispatch) => { $.ajax('xxx/products', { success: (data) => { disptach({ type: GET_PRODUCTS data" data }); } } } } 也就是外部觸發 actions 時才去做 ajax 流程:action -> ajax --> ajax success callback -> dispatch 2. 將 ajax 的行為都定義在其他地方, actions 只作簡單定義 ,例如 ProductionActions.js export function getAllProduction () { return { type: GET_PRODUCTS data" data }); } ==== 其他 ===== const actions = bindActionCreators(ProductionActions, dispatch); 某個地方呼叫 ajax ,傳入已綁定好的 actions 如上 $.ajax('xxx/productions, { success: actions.getAllProduction } 流程:ajax -> ajax success callback -> action -> dispatch 以上,不曉得有沒有人知道我在問什麼?