Skip to content

Commit

Permalink
Add update method, remove getters..
Browse files Browse the repository at this point in the history
This makes the osmNote work a bit more like other osm objects in iD.

- When working with the osm objects, we'll treat them as immutable.
  So all modifications will be through the update method:

  e.g. can do this in a repl, like chrome devtools console:
  >  n = iD.osmNote()
  osmNote { id: -1 }
  > n = n.update({ foo: 'bar' });
  osmNote { foo: "bar", id: -1, v: 1 }

- none of the other osm objects have getters, and in JavaScript all the
  properties are public anyway
  • Loading branch information
bhousel committed Jun 30, 2018
1 parent fd1d2f0 commit ede5610
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions modules/osm/note.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,7 @@ _extend(osmNote.prototype, {
return new geoExtent(this.loc);
},

getID: function() {
return this.id;
},

getType: function() {
return this.type;
},

getComments: function() {
return this.comments;
update: function(attrs) {
return osmNote(this, attrs, {v: 1 + (this.v || 0)});
}
});

1 comment on commit ede5610

@thomas-hervey
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bhousel this makes a lot of sense. These getters weren't being used yet anyways, but this helps clarify how updates work. Thanks!

Please sign in to comment.