Public Lab

Add meaningful return values for toolbar manipulation methods

Problem

We have toolbar manipulation methods #addTool #removeTool and #replaceTool for L.DistortableImage.Edit:

https://github.com/publiclab/Leaflet.DistortableImage/blob/0a162b57aac8be4644a878901567f306c3c006ee/src/edit/DistortableImage.Edit.js#L211-L238

Currently, the return results for them could be more purposeful.

Solution

I think a good route to go would be to return false on failure like they already do, and the toolbar object itself on success to allow for chaining and more concise code. Open to other suggestions for a return value if you feel they would be better.

To complete:

  • addTool needs a meaningful return value on success (undefined currently)
  • removeTool needs a meaningful return value on success & failure (undefined currently)
  • replaceTool needs a meaningful return value on success (undefined currently)
  • document these return values in the README (just follow the current documentation pattern - see other tool related methods documented for reference)

Additional Information

Please find further information on installation, solving, & getting help on the linked issue.

Thank you 😊

Task tags

  • leaflet
  • medium
  • javascript

Students who completed this task

Sparks

Task type

  • code Code
  • chrome_reader_mode Documentation / Training
close

2019