Skip to content

Commit 9099fff

Browse files
committedJul 6, 2016
J5Redux boilerplate
1 parent bc6816c commit 9099fff

20 files changed

+23
-1240
lines changed
 

‎boilerplate/util/j5Redux.js

+23-11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ var isEqual = require('lodash.isequal');
44
var setJ5Components = require('../actions/j5ReduxActions').setJ5Components;
55
var addJ5Components = require('../actions/j5ReduxActions').addJ5Components;
66

7+
/**
8+
* The j5-redux class instantiates Johnny Five components and sets up a reference to them in
9+
* the redux store with a default state.
10+
*/
711

812
var initializers = {
913
/**
@@ -50,7 +54,7 @@ var initializers = {
5054
* Get what's stored in redux for this class
5155
* @param {string} store_name key everything in the class is stored under
5256
* @param {string} id j5_object id
53-
* @return {object} redux state
57+
* @returns {object} redux state
5458
*/
5559
getStore: function(store_name, id) {
5660
var state = store.getState();
@@ -84,7 +88,7 @@ var initializers = {
8488
};
8589

8690
/**
87-
* J5Components
91+
* J5Redux
8892
* @param {object} spec object
8993
* @param {object} spec.five - an object containing a Johnny five class & an array
9094
* arguments to instantiate it
@@ -153,13 +157,13 @@ var initializers = {
153157
}
154158
}
155159
}
156-
* @returns {Class J5Component} J5Component class
160+
* @returns {Class J5Redux} J5Redux class
157161
*/
158162

159163

160-
var Component = function(spec) {
161-
if (!(this instanceof Component)) {
162-
return new Component();
164+
var J5Redux = function(spec) {
165+
if (!(this instanceof J5Redux)) {
166+
return new J5Redux();
163167
}
164168
// set up cache ----------------------------
165169
this.state_cache = {};
@@ -190,30 +194,38 @@ var Component = function(spec) {
190194

191195
};
192196

193-
Component.prototype = {
197+
J5Redux.prototype = {
194198
/**
195199
* Get All j5 Components created inside here
196200
* note: if you manipulate them outside of redux state managment
197201
* the state will be out of sync
198-
* @return {object} - {j5Id: j5Component}
202+
* @returns {object} - {j5Id: j5Component}
199203
*/
200204
getJ5Objects: function() {
201205
return this.j5_objects;
202206
},
203207
/**
204208
* Get the redux store values created in here. Helpful for debugging
205209
* @param {string} j5_object_id - retrieve by id
206-
* @return {object} - redux state
210+
* @returns {object} - redux state
207211
*/
208212
getState: function(j5_object_id) {
209213
if (j5_object_id) {
210214
return store.getState('J5')[this.store_name][j5_object_id];
211215
}
212216
return store.getState('J5')[this.store_name];
213217
},
218+
/**
219+
* log out state for debugging
220+
* @returns {void}
221+
*/
214222
log: function() {
215223
console.log(this.getState());
216224
},
225+
/**
226+
* Reset redux state to defaults
227+
* @returns {void}
228+
*/
217229
resetReduxState: function(){
218230
var fiveIDArray = Object.keys(this.j5_objects);
219231
var defaults = this.default_store;
@@ -225,7 +237,7 @@ Component.prototype = {
225237

226238
// if test mode add initializer object to the export so I can test it :)
227239
if (process.env.IS_TEST_MODE) {
228-
Component.initializers = initializers;
240+
J5Redux.initializers = initializers;
229241
}
230242

231-
module.exports = Component;
243+
module.exports = J5Redux;

‎index.js

-28
This file was deleted.

‎pieman-app/Game.js

-187
This file was deleted.

‎pieman-app/actions/j5ReduxActions.js

-30
This file was deleted.

‎pieman-app/actions/piemanActions.js

-83
This file was deleted.

‎pieman-app/components/buttons.js

-178
This file was deleted.

‎pieman-app/components/onSwitch.js

-52
This file was deleted.

‎pieman-app/components/rgbLed.js

-86
This file was deleted.

‎pieman-app/constants/actionTypes.js

-19
This file was deleted.

‎pieman-app/pieman.fzz

-77.6 KB
Binary file not shown.

‎pieman-app/reducers/J5.js

-25
This file was deleted.

‎pieman-app/reducers/index.js

-7
This file was deleted.

‎pieman-app/reducers/pieman.js

-57
This file was deleted.

‎pieman-app/store/configureStore.js

-9
This file was deleted.

‎pieman-app/store/index.js

-13
This file was deleted.

‎pieman-app/util/j5Redux.js

-231
This file was deleted.

‎test/pieman/button.gamelistener.test.js

-91
This file was deleted.

‎test/pieman/pieman.actions.test.js

-78
This file was deleted.

‎test/pieman/pieman.game.test.js

-55
This file was deleted.

‎test/pieman/pieman.reducer.test.js

Whitespace-only changes.

0 commit comments

Comments
 (0)
Please sign in to comment.