From 069f8513130dd6e717a153b85684cd63b6d32a0e Mon Sep 17 00:00:00 2001
From: nickago <ngonella@calpoly.edu>
Date: Mon, 31 Aug 2015 10:10:22 -0700
Subject: Cosmetic Refactoring

---
 web/react/stores/error_store.jsx | 81 ++++++++++++++++++++++------------------
 1 file changed, 45 insertions(+), 36 deletions(-)

(limited to 'web/react/stores/error_store.jsx')

diff --git a/web/react/stores/error_store.jsx b/web/react/stores/error_store.jsx
index 203b692ec..597c88cff 100644
--- a/web/react/stores/error_store.jsx
+++ b/web/react/stores/error_store.jsx
@@ -3,7 +3,6 @@
 
 var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
 var EventEmitter = require('events').EventEmitter;
-var assign = require('object-assign');
 
 var Constants = require('../utils/constants.jsx');
 var ActionTypes = Constants.ActionTypes;
@@ -12,43 +11,53 @@ var BrowserStore = require('../stores/browser_store.jsx');
 
 var CHANGE_EVENT = 'change';
 
-var ErrorStore = assign({}, EventEmitter.prototype, {
-
-  emitChange: function() {
-    this.emit(CHANGE_EVENT);
-  },
-
-  addChangeListener: function(callback) {
-    this.on(CHANGE_EVENT, callback);
-  },
-
-  removeChangeListener: function(callback) {
-    this.removeListener(CHANGE_EVENT, callback);
-  },
-  handledError: function() {
-    BrowserStore.removeItem("last_error");
-  },
-  getLastError: function() {
-    return BrowserStore.getItem('last_error');
-  },
-
-  _storeLastError: function(error) {
-    BrowserStore.setItem("last_error", error);
-  },
-});
-
-ErrorStore.dispatchToken = AppDispatcher.register(function(payload) {
-  var action = payload.action;
-  switch(action.type) {
+class ErrorStoreClass extends EventEmitter {
+    constructor() {
+        super();
+
+        this.emitChange = this.emitChange.bind(this);
+        this.addChangeListener = this.addChangeListener.bind(this);
+        this.removeChangeListener = this.removeChangeListener.bind(this);
+        this.handledError = this.handledError.bind(this);
+        this.getLastError = this.getLastError.bind(this);
+        this.storeLastError = this.storeLastError.bind(this);
+    }
+
+    emitChange() {
+        this.emit(CHANGE_EVENT);
+    }
+
+    addChangeListener(callback) {
+        this.on(CHANGE_EVENT, callback);
+    }
+
+    removeChangeListener(callback) {
+        this.removeListener(CHANGE_EVENT, callback);
+    }
+    handledError() {
+        BrowserStore.removeItem('last_error');
+    }
+    getLastError() {
+        return BrowserStore.getItem('last_error');
+    }
+
+    storeLastError(error) {
+        BrowserStore.setItem('last_error', error);
+    }
+}
+
+var ErrorStore = new ErrorStoreClass();
+
+ErrorStore.dispatchToken = AppDispatcher.register(function registry(payload) {
+    var action = payload.action;
+    switch (action.type) {
     case ActionTypes.RECIEVED_ERROR:
-      ErrorStore._storeLastError(action.err);
-      ErrorStore.emitChange();
-      break;
+        ErrorStore.storeLastError(action.err);
+        ErrorStore.emitChange();
+        break;
 
     default:
-  }
+    }
 });
 
-module.exports = ErrorStore;
-
-
+export default ErrorStore;
-- 
cgit v1.2.3-1-g7c22

