once - Methods - Author API

Author API Methods


Set up a one-time event listener for a specified event that will execute the callback function once and then stop listening to the event.

You would want to use this method so that you can execute some custom logic the first time an event is fired, such as displaying a message the first time the author creates an Item, for example.


// Execute only once, the first time any Item has been saved.
authorApp.once('save:success', function (event) {
    console.log('Item has been saved.');

// Multiple events can be listened to (just once) using chained calls.
    .once('widgetedit:widget:changed', function (event) {
        console.log('The Widget has changed.');
    .once('widgetedit:preview:changed', function (event) {
        console.log('The preview has changed.');


  • eventName string

    Name of the event that you want to listen to.

  • eventCallback eventCallback

    Callback function that will be invoked whenever the event is fired.

  • context object

    Execution context that will be used for this when the callback function is invoked.

Return value

Type AuthorApp

Returns the current instance of Author API if successful.

Related articles

  • Author API events
  • The on() method, which allows you to unbind event listeners.
  • The off() method, which allows you to unbind event listeners.
Was this article helpful?

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