Skip to content

Instantly share code, notes, and snippets.

@surgeboris
Last active February 24, 2017 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save surgeboris/29f22c7a821b69ac212fda2054e3a092 to your computer and use it in GitHub Desktop.
Save surgeboris/29f22c7a821b69ac212fda2054e3a092 to your computer and use it in GitHub Desktop.
@@ -1,13 +1,13 @@
import Events from 'eventemitter3';
-const rawMixin = function () {
+const mixinModel = function (target) {
const attrs = {};
- return Object.assign(this, {
+ return Object.assign(target, {
set (name, value) {
attrs[name] = value;
- this.emit('change', {
+ target.emit('change', {
prop: name,
value: value
});
@@ -19,8 +19,6 @@ const rawMixin = function () {
}, Events.prototype);
};
-const mixinModel = (target) => rawMixin.call(target);
-
const george = { name: 'george' };
const model = mixinModel(george);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment