diff --git a/package.json b/package.json index c965375..b85eb2a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "focus-core", - "version": "2.2.0-beta2", + "version": "2.2.0-beta3", "description": "Focus library core part.", "main": "index.js", "babel": { diff --git a/src/history/index.js b/src/history/index.js index f9a918e..fe3fde9 100644 --- a/src/history/index.js +++ b/src/history/index.js @@ -1,29 +1,43 @@ let _navigate, _back, _start; // Define the navigation functions depending on backbone or react-router -export const setNavigationFunctions = (navigate, back, start) => { +const setNavigationFunctions = (navigate, back, start) => { _navigate = navigate; _back = back; _start = start; } -export const navigate = (...args) => { - if(!_navigate) { +const navigate = (...args) => { + if (!_navigate) { throw new Error('react-router or backbone URL Navigation was badly given in the setNavigationFunctions()') } _navigate(...args); } -export const back = (...args) => { - if(!_back){ +const back = (...args) => { + if (!_back) { throw new Error('react-router or backbone Previous Page Navigation was badly given in the setNavigationFunctions()') } _back(...args); } -export const start = (...args) => { - if(!_start) { +const start = (...args) => { + if (!_start) { throw new Error('Backbone start router was badly given in the setNavigationFunctions()') } _start(...args); } + +export { + setNavigationFunctions, + navigate, + back, + start +} + +export default { + setNavigationFunctions, + navigate, + back, + start +} \ No newline at end of file diff --git a/src/store/application/store.js b/src/store/application/store.js index bb4b84a..c2b5405 100644 --- a/src/store/application/store.js +++ b/src/store/application/store.js @@ -12,19 +12,16 @@ class ApplicationStore extends CoreStore { super(conf); } /** - * Update the mode value. - * @param {object} dataNode - The value of the data. - */ + * Update the mode value. + * @param {object} dataNode - The value of the data. + */ updateMode(dataNode) { - let modeData = this.data.has('mode') ? this.data.get('mode') : Immutable.fromJS({}); - let newModeValue = modeData.has(dataNode.newMode) ? (modeData.get(dataNode.newMode) + 1) : 1; - //Add a check to not have a negative mode, but it should not happen. - let previousModeValue = modeData.has(dataNode.previousMode) ? (modeData.get(dataNode.previousMode) - 1) : 0; - this.data = this.data.set('mode', - modeData.set(dataNode.newMode, newModeValue).set(dataNode.previousMode, previousModeValue) - ); + const modeData = (this.data.has('mode') ? this.data.get('mode') : Immutable.fromJS({})) + .set(dataNode.newMode, 1) + .set(dataNode.previousMode, 0); + this.data = this.data.set('mode', modeData); this.willEmit('mode:change'); } } -export default ApplicationStore; +export default ApplicationStore; \ No newline at end of file