Subscribing to general application events through PageBus should be fairly safe and easy to do.
Subscribe to events like this:
HD.PageBus.subscribe('*.*.entity.select', this.onEntitySelect, this);
Inline example for testing:
A raw entity will be returned. Easiest way to get currently selected objects, would be to use high level EmbededApi call: HD.EmbededApi.getSelectedObjects();
Otherwise raw entity ID must be looked up against links store. The links store will present internal object ID with information about default link.
That data can be then converted to external ID.
Vector entities / spots
Returned data contains information both about the vector entity and a default linked object to that spot, if any.
For more information, a docSvgView object is provided for further interaction.
Basic support for key events is added:
Use specific key subscription or for all keys, subscribe to generic "key" event.
In the handler function
data object will contain :
To obtain object selection after event (in embedded scenario), call HD.EmbededApi.getSelectedObjects();
Using pagebus events
Publish a message on a topic. If there is an event cache for this topic, a copy of the message will also be saved in the event cache.
Subscribe to a topic. With certain parameters, also creates a cache for the specified topic.
Cancel a subscription created by subscribe().
Query the cache for events matching the specified topic.
If there is a cache for the specified topic, publish to update it. Otherwise throw an exception so that the caller knows that the topic is not cache-enabled.
System Ready Event
System ready event is fired when the main interface loads. When navigating to another module, e.g. System Administration, the event will be fired again when going back to main interface.
Access to this information is available in the following way:
- Make sure HD.EmbeddedApi is available (exists)
- Callback function
- Context for callback
- any additional arguments that will be passed on to callback function (variable, object etc)
The callback will be always called, either imminently if the system is already in Ready state, or later is the system is still initializing.
To clear all System Ready subscriptions, call this function without arguments:
To list current subscribers:
If you do not want to provide callback function, you can call this function that will check current state: