1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-16 01:55:07 +01:00
onion/js/stores/piece_store.js
2015-07-13 18:13:16 +02:00

27 lines
623 B
JavaScript

'use strict';
import alt from '../alt';
import PieceActions from '../actions/piece_actions';
class PieceStore {
constructor() {
this.piece = {};
this.bindActions(PieceActions);
}
onUpdatePiece(piece) {
this.piece = piece;
}
onUpdateProperty({key, value}) {
if(this.piece && key in this.piece) {
this.piece[key] = value;
} else {
throw new Error('There is no piece defined in PieceStore or the piece object does not have the property you\'re looking for.');
}
}
}
export default alt.createStore(PieceStore, 'PieceStore');