Skip to content

Commit 71ed96f

Browse files
committed
refactoring
1 parent 93e96c1 commit 71ed96f

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-ls",
3-
"version": "2.2.21",
3+
"version": "2.3.0",
44
"description": "Vue plugin for work with LocalStorage from Vue context",
55
"main": "dist/vue-ls.js",
66
"authors": [

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-ls",
3-
"version": "2.2.21",
3+
"version": "2.3.0",
44
"description": "Vue plugin for work with LocalStorage from Vue context",
55
"main": "dist/vue-ls.js",
66
"jsnext:main": "src/index.js",

src/event.js

+7-11
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,17 @@ export default class {
2020
static emit(event) {
2121
const e = event || window.event;
2222

23-
const fire = (listener) => {
24-
let newValue;
25-
let oldValue;
26-
23+
const getValue = (data) => {
2724
try {
28-
newValue = JSON.parse(e.newValue).value;
25+
return JSON.parse(data).value;
2926
} catch (err) {
30-
newValue = e.newValue;
27+
return data;
3128
}
29+
};
3230

33-
try {
34-
oldValue = JSON.parse(e.oldValue).value;
35-
} catch (err) {
36-
oldValue = e.oldValue;
37-
}
31+
const fire = (listener) => {
32+
const newValue = getValue(e.newValue);
33+
const oldValue = getValue(e.oldValue);
3834

3935
listener(newValue, oldValue, e.url || e.uri);
4036
};

0 commit comments

Comments
 (0)