Events subscriptions
Â
Introduction
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:
var myHandler = function(subject, data) { console.log(data) }; HD.PageBus.subscribe('*.*.user.spot.select', this.myHandler, this);
Â
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.
Â
Events
Object entities
*.*.entity.select
*.*.entity.update
*.*.entity.create
Vector entities / spots
*.*.user.spot.select
HD.PageBus.subscribe('*.*.user.spot.select', function(event, data) {
console.log(data);
});
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.
Object {entityId: "ENT-1976", entity: g#ENT-1976, docSvgView: constructor, targetObject: Object}
-> docSvgView:constructor
-> entity:g#ENT-1976
-> entityId:"ENT-1976"
-> targetObject:Object
-> classId:"108"
-> isDefault:false
-> objectId:"5194"
Key Events
Basic support for key events is added:
ui.docview.key.Delete
ui.docview.key.Enter
ui.docview.key.Escape
ui.docview.key
Use specific key subscription or for all keys, subscribe to generic "key" event.
In the handler functionÂ
function(subject, data)
data object will contain :
SvgView
event
To obtain object selection after event (in embedded scenario), call HD.EmbededApi.getSelectedObjects();
Viewer Events
ui.docview.document.load
ui.docview.document.clearÂ
ui.docview.document.ready Â
 Document "load" will only be fired on actual document load and will not be fired when only object context was changed.
Context change happens when the same document is used to show another object, e.g. Room. Instead, you might want to use 'ready' event, unless you are interested in actual load event.Â
Â
Using pagebus events
Â
Function | Comment |
---|---|
PageBus.publish | 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. |
PageBus.subscribe | Subscribe to a topic. With certain parameters, also creates a cache for the specified topic. |
PageBus.unsubscribe | Cancel a subscription created by subscribe(). |
PageBus.query not available | Query the cache for events matching the specified topic. |
PageBus.store not available | Â 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
Since 3.7
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)
CallÂ
Â
Arguments are:
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: