Javascript scoping is not at all intuitive to me, and the event loop in the gist (see below, canvasImg.js) is difficult to combine with other javascript event listener
loops that I'm trying to implement.
Currently, I'm attempting to create a custom input binding for shiny that produces the same behavior as the following javascript behavior:
I'd like to extend selectInputBinding from shiny.js to produce a new image reference and to redraw canvas whenever a new selection from the drop down menu occurs.
The problem with canvasImg.js is that the event loop is continuous, not conditional like the reactive functions in shiny.
It might be possible to use an approach similar to the extension of textInputBinding in shiny.js:
var textareaInputBinding = {};
$.extend(textareaInputBinding, textInputBinding, {
find: function(scope) {
return $(scope).find('textarea');
}
});
inputBindings.register(textareaInputBinding, 'shiny.textareaInput');
I think that I need to understand the following terms/concepts so that I can create a custom shiny input:
1) scope (The dropdown selector, canvas, & new image need to be included for the namespace/closure.)
2) return (I anticipate that return would be the mechanism to instruct canvas to draw the new image node)
3) callback (I think a callback is needed to update multiple canvases with multiple different images from a single dropdown selection. From what I understand, callbacks are heart of communication between multiple javascript processes.)
Thanks in advance!