call / api
call() / api() are functions to trigger the Redux store.dispatch() function.


Refer to the above architecture diagram, call() directly dispatches the action to Redux Store.  api() makes an asynchronous call to the backend API first, then dispatches the action upon callback from the backend.  If an error occurs, it will trigger the error handling function and stop the store dispatch action.

call(name, param, callback)

#
name: string

Name of actions in Reducer
param: any
Single value or object passed to action in Reducer
callback: function
Callback function with error message as parameter: (error) => {}

You can put another call / api within this function.

Note: You do not have to handle error messages using this callback function. The system can display the error message automatically.

Return

#
None

Example

#
<Button onClick={() => call('recalc', reducer['finance/summary'])}>
   Recalc
</Button>
Call the recalc action by passing the Reducer of module finance/summary as param

api(name, param, callback)

#
The arguments are the same as call().

Return

#
None

Example

#
<Button onClick={() => api('save', _.fields, popup(Done))}>
   Save
</Button>
Call the save backend API by passing all fields in Reducer as param, then popup the Done dialog.