Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: dregend devine
Added: Jul 3, 2018 6:18 PM
Views: 14
Tags: no tags
  1. var simpleMVC = (function simpleMVC(simple) {
  2.   'use strict';
  3.  
  4.   simple.Model = function SimpleModel(data) {
  5.     this._data = data;
  6.  
  7.     this.onSet = new simple._Event(this);
  8.   };
  9.  
  10.   // define getters and setters
  11.   simple.Model.prototype = {
  12.     // get just returns the value
  13.     get() {
  14.       return this._data;
  15.     },
  16.     // sets the value and notifies any even listeners
  17.     set(data) {
  18.       this._data = data;
  19.       this.onSet.notify({ data: data });
  20.     },
  21.   };
  22.  
  23.   return simple;
  24. })(simpleMVC || {});
  25. view raw