-
Notifications
You must be signed in to change notification settings - Fork 66
Triggers
Triggers are the engine of Dropchops codebase. We are using jQuery's trigger() as our publication/subscription service throughout the code, which allows us to "publish" actions across dropchop that can be picked up by any "subscriber" throughout the code. For example, we use this one quite a bit:
$(dc).trigger('file:added', [layer]);The above publishes the file:added action which other pieces of the code are listening for. We can pick up this trigger in layers.dropchop.js by writing:
$(dc).on('file:added', addFileToLayers);
addFileToLayers = function(event, layer) {
// do something with layer
}The addFileToLayers() function will run with the event parameter first, every time, and then any options that are passed in the original array from the trigger. In the above case, an array of one element layer is passed as receiving information.
Below is a list of triggers that exist within dropchop that can be picked up anywhere when fired.
Operations
operation:geo:TURF-OPERATIONoperation:file:FILE-OPERATION
Layers
file:addedlayer:duplicatelayer:removelayer:removedlayer:showlayer:hidelayer:selectedlayer:unselectedlayer:addedlayer:renamelayer:renamed
Forms
form:geoform:file