Playing Around with Bootstrap Object
Bootstrap is an object with all the necessary data for displaying a certain page. It's data is outputted in console on every load:
You might need something from this object, but the problem is that Bootstrap is not globally available:
We also couldn't know at which point of time is it loaded so we could require it:
bootstrap = require('bootstrap');
It is quite easy to implement event dispatcher which we can listen and it will tell us when Bootstrap is loaded. First you need to find where in the files the load happens:
grep -Rin "console.log('bootstrap', Bootstrap);" engine/
In those files you need to dispatch the actual event so you can listen later. Steps:
- Add event dispatcher (core/event_dispatcher) to the list of dependencies.
- Add event dispatcher (eventDispatcher) to the definition function as function argument on the same position as you add it to dependencies.
- Dispatch the bootstrap loaded event:
Here is an example of all three changes:
When you have done upper steps, you can listen to it on any page you want with this code: