focus-core 2.2.0-beta4
Pre-release
Pre-release
Since beta3 :
- Adding shorthand for dispatch
- Removing XHR request, now using fetch API
- Action now return data
- Adding api-driver, and fetch transformations
Dispatch
Before, to dispatch, it was needed to do :
import dispatcher from 'focus-core/dispatcher';
dispatcher.handleServerAction({
data: {
node: dataForNode
}, type: 'update'
});
Now you can do
import {dispatchData} from 'focus-core/dispatcher';
dispatchData('node', dataForNode);
// Identifier can be precised
dispatchData('node', dataForNode, identifier);
Also working for multiple node and data, with different format
import {dispatchData} from 'focus-core/dispatcher';
const toDispatch = {
node1: dataForNode1,
node2: dataForNode2
};
dispatchData(toDispatch);
// Identifier can be precised
dispatchData(toDispatch, identifier);
Fetch
Configuration from there is now native configuration for fetch (see this), except for xhrErrors
object, which is still a focus-feature for handling error.
Default behaviour should be conform to old XHR behaviour.
Api Driver
Api driver is an utility which can be used, to simplify fetch call.
Files can be generated using focus-service-generator.
Now, you can add before-fetch, and after-fetch transformations, for every request (useful for CSRF token, adding headers, ...)
You can see example there and there