focus-core 2.2.0
Breaking changes :
- Numeral : the version has been updated, the initialisation has changed
- i18next : the version has been updated (no more i18next-client), the initialisation has changed. Moreover, the __variable__ declaration doesn't work anymore. You need to change to {{variable}}
What's in it :
- Re-writing all code in ES6
- Unit testing migrated in jest
- Advanced search : can now have several stores/advanced search properly separed
- #396 #399 Store : name collision with error, status are now tested
- [BUGFIX] #393 #401 ActionBuilder for list : The number of element can now be changed correctly
- [BUGFIX] Fixing reference store : adding new method
- 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