2015-06-05 11:06:36 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-10-06 16:47:59 +02:00
|
|
|
import { alt } from '../alt';
|
2015-05-26 10:41:41 +02:00
|
|
|
import PieceFetcher from '../fetchers/piece_fetcher';
|
|
|
|
|
|
|
|
|
|
|
|
class PieceActions {
|
|
|
|
constructor() {
|
|
|
|
this.generateActions(
|
2015-07-13 18:13:16 +02:00
|
|
|
'updatePiece',
|
2015-10-19 15:58:05 +02:00
|
|
|
'updateProperty',
|
|
|
|
'pieceFailed'
|
2015-05-26 10:41:41 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchOne(pieceId) {
|
|
|
|
PieceFetcher.fetchOne(pieceId)
|
|
|
|
.then((res) => {
|
|
|
|
this.actions.updatePiece(res.piece);
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
2015-07-17 15:41:09 +02:00
|
|
|
console.logGlobal(err);
|
2015-10-19 16:01:05 +02:00
|
|
|
this.actions.pieceFailed(err.json);
|
2015-05-26 10:41:41 +02:00
|
|
|
});
|
|
|
|
}
|
2015-05-26 13:33:35 +02:00
|
|
|
}
|
2015-05-26 10:41:41 +02:00
|
|
|
|
|
|
|
export default alt.createActions(PieceActions);
|