Skip to content

Commit

Permalink
Refactored, focus on playback
Browse files Browse the repository at this point in the history
  • Loading branch information
Holyoke committed Jun 3, 2015
1 parent 82be2a9 commit 38bc571
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/components/key.js.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var Key = React.createClass({
getInitialState:function () {
return { notes: KeyStore.all(), color: '#D3D3D3', scale: 'scale(1)' }
return { color: '#D3D3D3', scale: 'scale(1)' }
},
_onChange: function () {
var notes = this.state.notes;
var notes = KeyStore.all();
var key = this.props.noteName;
if (notes[key]) {
this.note.start();
Expand Down
15 changes: 9 additions & 6 deletions app/assets/javascripts/stores/KeyStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

root.KeyStore = $.extend({}, EventEmitter.prototype, {
all: function () {
return _keys;
return JSON.parse(JSON.stringify(_keys));
},

addChangeListener: function(callback){
this.on(CHANGE_EVENT, callback);
},
Expand All @@ -16,12 +15,16 @@
dispatcherID: AppDispatcher.register(function(payload) {
switch(payload.actionType) {
case KeyConstants.KEY_PRESSED:
_keys[payload.key] = payload.key;
KeyStore.emit(CHANGE_EVENT);
if (!_keys[payload.key]) {
_keys[payload.key] = payload.key;
KeyStore.emit(CHANGE_EVENT);
}
break;
case KeyConstants.KEY_RELEASED:
delete _keys[payload.key];
KeyStore.emit(CHANGE_EVENT);
if (_keys[payload.key]) {
delete _keys[payload.key];
KeyStore.emit(CHANGE_EVENT);
}
break;
}
})
Expand Down

0 comments on commit 38bc571

Please sign in to comment.