One of my html menus is getting rather complex and as a result the Ruby code that talks to it is also getting more complex. My concern is that by defining too many callbacks it will cause problems. Is there any practical limit on the number of callbacks you can define?
The only practical limit I can think of is when the code gets difficult to read. 10 lines of code is the recommended max length for a method body. I typically have one method for creating a HtmlDialog object and one for attaching callbacks, where each callback is just one single line of code calling yet another a dedicated method. This allows for 10 callbakcs without breaking this recommendation, but if needed it can be broken.
I’ve set up multiple call backs in one method since I am trying to break up the amount of data transferred between Ruby and the HTML into smaller blocks, hence the large number of callbacks within a single method, so far it seems to work just fine, but this sort of thing always worries me I guess.
Some coders write one data gathering callback and then within it “taste” the first item or key of data, and then use that to decide what local method to call within their custom class.
There are two ways for custom class. A wrapper class that holds a normal API dialog object, or a custom subclass of the API dialog class. I find the custom subclasses more intuitive. (We’ve posted quite a few examples here in these forums.)
Not that I’ve run into. But with WebDialog there is a limit to the size or params calling back. And in HtmlDialogs, while it shouldn’t have that limitation, I did run into a crash in some erratic cases when I passed a really large object. (Though converting that same object to a JSON string worked around it.)