Page tree
Skip to end of metadata
Go to start of metadata



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


HD.PageBus.subscribe('ui.docview.document.load', function(subject, data) {
	//DocView is passed as an argument
    var docView = data;
	//get Svg Viewer (if composite document was loaded)
    var docSvgView = docView.down('docsvgview');
	//get data/information about loaded content
    var docData = docSvgView.getData();
    console.log(docData);
});



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

(warning) not available

Query the cache for events matching the specified topic.

PageBus.store

(warning) 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:

  1. Make sure HD.EmbeddedApi is available (exists)
  2. Call 

    HD.EmbeddedApi.onSystemReady(function(){
    	console.log('System ready received!');
    }, this, {a:1});

Arguments are:

  1. Callback function
  2. Context for callback
  3. 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:

HD.EmbeddedApi.onSystemReady();

To list current subscribers:

HD.EmbeddedApi.getSystemReadySubscribers();


If you do not want to provide callback function, you can call this function that will check current state:

HD.EmbeddedApi.isSystemReady()



  • No labels