Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinCK committed Jul 20, 2017
1 parent 93e96c1 commit 71ed96f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-ls",
"version": "2.2.21",
"version": "2.3.0",
"description": "Vue plugin for work with LocalStorage from Vue context",
"main": "dist/vue-ls.js",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-ls",
"version": "2.2.21",
"version": "2.3.0",
"description": "Vue plugin for work with LocalStorage from Vue context",
"main": "dist/vue-ls.js",
"jsnext:main": "src/index.js",
Expand Down
18 changes: 7 additions & 11 deletions src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,17 @@ export default class {
static emit(event) {
const e = event || window.event;

const fire = (listener) => {
let newValue;
let oldValue;

const getValue = (data) => {
try {
newValue = JSON.parse(e.newValue).value;
return JSON.parse(data).value;
} catch (err) {
newValue = e.newValue;
return data;
}
};

try {
oldValue = JSON.parse(e.oldValue).value;
} catch (err) {
oldValue = e.oldValue;
}
const fire = (listener) => {
const newValue = getValue(e.newValue);
const oldValue = getValue(e.oldValue);

listener(newValue, oldValue, e.url || e.uri);
};
Expand Down

0 comments on commit 71ed96f

Please sign in to comment.