mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2025-12-20 21:20:50 +01:00
36 lines
683 B
JavaScript
36 lines
683 B
JavaScript
import Store from 'fluxible/addons/BaseStore';
|
|
|
|
class ViaPointStore extends Store {
|
|
static storeName = 'ViaPointStore';
|
|
|
|
viaPoints = [];
|
|
|
|
addViaPoint(val) {
|
|
this.viaPoints.push(val);
|
|
this.emitChange();
|
|
}
|
|
|
|
setViaPoints(viaPoints) {
|
|
this.viaPoints = [...viaPoints];
|
|
this.emitChange();
|
|
}
|
|
|
|
getViaPoints() {
|
|
return this.viaPoints;
|
|
}
|
|
|
|
deleteViaPoint(val) {
|
|
this.viaPoints = this.viaPoints.filter(
|
|
p => p.lat !== val.lat || p.lon !== val.lon,
|
|
);
|
|
this.emitChange();
|
|
}
|
|
|
|
static handlers = {
|
|
addViaPoint: 'addViaPoint',
|
|
setViaPoints: 'setViaPoints',
|
|
deleteViaPoint: 'deleteViaPoint',
|
|
};
|
|
}
|
|
|
|
export default ViaPointStore;
|