import { observable } from "mobx" ; export class Coordinate { @ observable live : number ; @ observable private committed : number ; constructor ( value ? ) { this . json = value || 0 ; } offset ( delta ) { this . live += delta ; } /** Pass true to commit the live value, or false to revert to the committed value */ commit ( keep ) { if ( keep ) { this . committed = this . live ; } else { this . live = this . committed ; } } get json ( ) { return this . committed ; } set json ( value ) { this . live = this . committed = value ; } }