Created
August 31, 2018 17:56
-
-
Save mweststrate/83cfbfd88ee271b3603d88649ce50598 to your computer and use it in GitHub Desktop.
No concurrency
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onStopDrag = (id, { dx, dy }) => { | |
// we capture this outside the propose closure! | |
const baseBox = this.client.currentState.boxes.find(b => b.id === id); | |
this.client.propose(draft => { | |
const box = draft.boxes.find(b => b.id === id); | |
if (box.x !== baseBox.x || box.y !== baseBox.y) | |
throw "Somebody else already dragged this box!"; | |
box.x += dx; | |
box.y += dy; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment