There are already some events defined such as 'render', 'load', 'move'.
Can you give me an example of how I can add a custom event to the Map object and then fire it?
Thanks
@misterfresh You can register an event handler with on and then fire it when you want the function to be called. i.e.
var map = new mapboxgl.Map({container:document.createElement('div')});
map.on('foo', function() { alert('bar'); })
map.fire('foo');
Thanks, this works!
@tristen Is the fire method still available? Otherwise its seems undocumented :/
@Fractaliste this is no longer public as of 0.45.0. You'll need to bring your own event emitter package.
@tristen Can you give us an example of a package that we'd use in the browser for this?
@chriszrc here's a few! http://microjs.com/#event%20emitter
Most helpful comment
@misterfresh You can register an event handler with
onand thenfireit when you want the function to be called. i.e.