function listenOnce(target, type, listener, thisArg) {
  return listen(target, type, listener, thisArg, true);
}
Registers a one-off event listener on an event target. Inspired by
https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html

This function efficiently binds a `listener` as self-unregistering listener
to a `this` object, and returns a key for use with
{@link module:ol/events.unlistenByKey} in case the listener needs to be
unregistered before it is called.

When {@link module:ol/events.listen} is called with the same arguments after this
function, the self-unregistering listener will be turned into a permanent
listener.

@param {import("./events/Target.js").EventTargetLike} target Event target.
@param {string} type Event type.
@param {ListenerFunction} listener Listener.
@param {Object} [thisArg] Object referenced by the `this` keyword in the
    listener. Default is the `target`.
@return {EventsKey} Key for unlistenByKey.