Skip to content

Commit

Permalink
set -> update
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrsh committed May 23, 2018
1 parent 047ac2e commit f2e8484
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 31 deletions.
30 changes: 14 additions & 16 deletions dist/moon.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,19 @@
this.emit("created");
};

var update = function() {
var update = function(key, value) {
var this$1 = this;

if (key !== undefined) {
if (typeof key === "object") {
for (var childKey in key) {
this$1.data[childKey] = key[childKey];
}
} else {
this.data[key] = value;
}
}

if (this.queued === false) {
this.queued = true;

Expand All @@ -494,19 +506,6 @@
this.emit("destroyed");
};

var set = function(key, value) {
var this$1 = this;

if (typeof key === "object") {
for (var childKey in key) {
this$1.set(childKey, key[childKey]);
}
} else {
this.data[key] = value;
this.update();
}
};

var on = function(type, handler) {
var data = this.data;
var handlers = data[type];
Expand Down Expand Up @@ -554,6 +553,7 @@
var this$1 = this;

this.name = name;
this.queued = false;

this.view = options.view.map(function (view) { return view.bind(this$1); });
this.m = m();
Expand All @@ -564,11 +564,9 @@
data[action] = actions[action].bind(this$1);
}

this.queued = false;
this.create = create;
this.update = update;
this.destroy = destroy;
this.set = set;
this.on = on;
this.off = off;
this.emit = emit;
Expand Down
2 changes: 1 addition & 1 deletion dist/moon.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 12 additions & 14 deletions src/component/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ const create = function(root) {
this.emit("created");
};

const update = function() {
const update = function(key, value) {
if (key !== undefined) {
if (typeof key === "object") {
for (let childKey in key) {
this.data[childKey] = key[childKey];
}
} else {
this.data[key] = value;
}
}

if (this.queued === false) {
this.queued = true;

Expand All @@ -23,17 +33,6 @@ const destroy = function() {
this.emit("destroyed");
};

const set = function(key, value) {
if (typeof key === "object") {
for (let childKey in key) {
this.set(childKey, key[childKey]);
}
} else {
this.data[key] = value;
this.update();
}
};

const on = function(type, handler) {
let data = this.data;
let handlers = data[type];
Expand Down Expand Up @@ -79,6 +78,7 @@ const emit = function(type, data) {
export const component = (name, options) => {
return function MoonComponent() {
this.name = name;
this.queued = false;

this.view = options.view.map((view) => view.bind(this));
this.m = m();
Expand All @@ -89,11 +89,9 @@ export const component = (name, options) => {
data[action] = actions[action].bind(this);
}

this.queued = false;
this.create = create;
this.update = update;
this.destroy = destroy;
this.set = set;
this.on = on;
this.off = off;
this.emit = emit;
Expand Down

0 comments on commit f2e8484

Please sign in to comment.