Using Public Methods in the readyListener Callback Function

As per the reference documentation, a readyListener callback function can be passed to the Author API init function, which gets called when some public methods can be used.

This article provides information about when public methods can be called -
either directly in the readyListener, or after some event.

Note that some public methods can only be called in a certain mode, if that is the case then the mode is mentioned alongside the public methods below.

Methods which can be called immediately

The following methods can be called directly in the readyListener without the need to wait for any events to be fired.

Methods which can be called only after an event is fired

As mentioned above, some methods can only be called after an event is fired. To handle this, inside your readyListener, set up an event listener, using the relevant event name, like so:

function readyListener() {
authorAppInstance.on('render:item', function() {
const item = authorAppInstance.getItem();

After 'render:activity' event

The methods below can only be called only when initializing in mode 'activity_edit':

After the render:item event

All below methods can only be called only when initializing in mode activity_edit:

After 'render:itemlist' or 'render:activitylist' 

After any render event

Methods which should not be called

Whilst these methods are available, there would be no benefit to call in the readyListener.

Was this article helpful?

Did you arrive here by accident? If so, learn more about Learnosity.