align Cedar's event API w/ that of the JSAPI
- Dominant language
- Handlebars
- Stars
- 265
- Forks
- 236
- PR merge metrics
- No merged PRs in 30d
Description
Looks like [implementation of `.off()` is incomplete](https://github.com/Esri/cedar/blob/master/src/cedar.js#L589).
Also from @ycabon:
The API for `on()` is different from the rest of the API. It doesn't return a handler `{ remove: function() }` but instead requires calling `off()`. I like `off()` over the handler pattern but for consistancy, on() should return an handler.
The event is payload should be one object. with at least a target property, the one that emitted the event.
``` html
//setup a chart using a json file that is the complete definition
var chart = new Cedar({
"definition":"../../../cedar/data/definitions/scatter-events.json"
});
//render the chart
chart.show({
elementId: "#chart"
});
//attach handler (can also be done before .show())
var hdl = chart.on('click', function (event){
hdl.remove();
//dump event to console such as mouse location...
console.dir(event.location);
//dump data to console...
console.dir(event.data);
});
window.onresize = function() { chart.update() }
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.