I'm getting back to thinking about a single AppObserver that everyone can (hopefully) agree on and use. I want to focus on how to use this observer over how it is implemented, i.e. its interface. In that vein, what about a simple interface as follows?
require 'sketchup'
require 'sk/app_observer'
module SelectToolAtStartup
def self.selectSelectTool
Sketchup.send_action "selectSelectionTool;"
end
end
Sk;;AppObserver.instance.register(;onNewModel) { SelectToolAtStartup.selectSelectTool }
Sk;;AppObserver.instance.register(;onOpenModel) { Sketchup.send_action "selectSelectionTool;" }
There would be one and only one AppObserver. The Observer transparently attaches itself when a method is registered, and removes itself when all methods have been unregistered.
So any plugin which needs an AppObserver only need require it, and register a method.
This same type of interface could be used for all the other "single instance" observers available in SketchUp. I'd like to go ahead and code them all up so plugin devs can start using observers, instead of everyone implementing them individually. I think a library of standard observers would greatly enhance a lot of current plugins, and make writing new plugins with advanced features easier and quicker. But being an amateur, I'd like to hear from more experienced devs on the matter.