These are chat archives for nmielnik/797ContextAwareToolbar

29th
Feb 2016
David Anderson
@davideanderson
Feb 29 2016 19:25
I do have one question for you @nmielnik . Is there any way for this extension to build up the buttons list for the toolbar extension. As I currently have it, the user has to provide the buttons array (which includes any button that will show up in any state) to the toolbar extension, and then include the button lists again in the configuration of my extension. It would be very cool if my extension could simply go through and find all the buttons used by any of the states, and then automatically initialize the toolbar extension with that array, rather than requiring the user to do it. I thought I might be able to do a getExtensionByName in my init(), but the toolbar extension doesn't exist when my init is called.
Nate Mielnik
@nmielnik
Feb 29 2016 19:28
@davideanderson so the code intentionally initializes the toolbar extension last, so that all button extensions have a chance to initialize before hand
so, you could do two things
three things actually
This message was deleted
1) Each time the logic in your extension runs, it can grab the list of buttons from the toolbar extension
2) You can wait until the first time the toolbar renders, calculate the list of buttons, and cache that as the default state
3) You can do a setTimeout(..., 0) inside init
and once that setTimeout() runs, you'll be able to do getExtensionByName('toolbar')
either way, you can always call this.base.extensions.forEach() and iterate through the extensions and find ones that implement getButton() and assume they're buttons that would display in the toolbar during the default state
you'd want to wait for all extensions to initialize regardless, because you can't assume the order that they initialize (except that the toolbar will always be last)