As per the reference documentation, a readyListener callback function can be passed to the Author API init function, which gets called when some methods can be used.
This article provides information about when methods can be called -
either directly in the readyListener, or after some event.
Note that some methods can only be called in a certain mode, if that is the case then the mode is mentioned alongside the 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.
-
createActivity(when initializing in mode 'activity_list') -
createItem(when initializing in mode 'item_list') -
editActivity(when initializing in mode 'activity_list') -
editItem(when initializing in mode 'item_list') editorAppmoveInstanceTonavigateononce-
setActivity(when initializing in mode 'activity_edit')
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':
changeActivityModeduplicateActivity-
getActivity getActivityItemsgetActivityReferencegetActivityStatus-
getActivityTags -
setActivity -
setActivityItems setActivityStatussetActivityTags
After the render:item event
All below methods can only be called only when initializing in mode activity_edit:
-
changeItemMode duplicateItem-
getItem getItemReference-
getItemTags getScoringTypegetStatusquestionsAppsetItemReferencesetItemTagssetScoringTypesetStatussetWidget
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.