Skip to content

Commit d2a83fc

Browse files
committed
Add history listener
1 parent 970034a commit d2a83fc

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/framework/commons/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module.exports = {
33
FRAMEWORK_MESSAGE_INIT_DEBUG: 'FRAMEWORK_MESSAGE_INIT_DEBUG',
44
FRAMEWORK_MESSAGE_DEBUG: 'FRAMEWORK_MESSAGE_DEBUG',
55

6+
FRAMEWORK_MESSAGE_CHANGE_URL: 'FRAMEWORK_MESSAGE_CHANGE_URL',
7+
68
FRAMEWORK_MESSAGE_PAGE_CELL_WAS_SELECTED: 'FRAMEWORK_MESSAGE_PAGE_CELL_WAS_SELECTED',
79
FRAMEWORK_MESSAGE_CONTEXT_MENU_CLICKED: 'FRAMEWORK_MESSAGE_CONTEXT_MENU_CLICKED',
810
FRAMEWORK_MESSAGE_COMPONENT_ITEM_WAS_DROPPED: 'FRAMEWORK_MESSAGE_COMPONENT_ITEM_WAS_DROPPED',

src/framework/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ export const initStore = (name, version, initialState = {}) => {
3333
window.parent.postMessage(message, '*');
3434
}
3535
};
36+
// Listen for changes to the current location.
37+
history.listen((location) => {
38+
// location is an object like window.location
39+
window.__sendFrameworkMessage({
40+
type: constants.FRAMEWORK_MESSAGE_CHANGE_URL,
41+
payload: `${location.pathname}${location.search}${location.hash}`,
42+
});
43+
});
3644
}
3745
};
3846

src/framework/store/sequences.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import isArray from 'lodash/isArray';
66
import isObject from 'lodash/isObject';
77
import isEmpty from 'lodash/isEmpty';
88
import unionWith from 'lodash/unionWith';
9-
import isEqual from 'lodash/isEqual';
109
import { COMPONENT_TYPE, USER_FUNCTION_TYPE } from './constants';
1110
import frameworkFunctions from './functions';
1211

0 commit comments

Comments
 (0)