Module

utils/emittermixin

@ckeditor/ckeditor5-utils/src/emittermixin

module

Filtering

Interfaces

Type Definitions

Functions

  • EmitterMixin( base ) → Mixed<Base, Emitter>

    Mixin that injects the events API into its host.

    This function creates a class that inherits from the provided base and implements Emitter interface.

    class BaseClass { ... }
    
    class MyClass extends EmitterMixin( BaseClass ) {
    	// This class derives from `BaseClass` and implements the `Emitter` interface.
    }
    

    Read more about the concept of emitters in the:

    Type parameters

    Base : extends Constructor

    Parameters

    base : Base

    Returns

    Mixed<Base, Emitter>
  • EmitterMixin() → new () => Emitter

    Mixin that injects the events API into its host.

    This function creates a class that implements Emitter interface.

    class MyClass extends EmitterMixin() {
    	// This class implements the `Emitter` interface.
    }
    

    Read more about the concept of emitters in the:

    Returns

    new () => Emitter
  • internal

    _getEmitterId( emitter ) → string | undefined

    Returns emitter's unique id.

    Parameters

    emitter : Emitter

    An emitter which id will be returned.

    Returns

    string | undefined
  • internal

    _getEmitterListenedTo( listeningEmitter, listenedToEmitterId ) → Emitter | null

    Checks if listeningEmitter listens to an emitter with given listenedToEmitterId and if so, returns that emitter. If not, returns null.

    Parameters

    listeningEmitter : Emitter

    An emitter that listens.

    listenedToEmitterId : string

    Unique emitter id of emitter listened to.

    Returns

    Emitter | null
  • internal

    _setEmitterId( emitter, [ id ] ) → void

    Sets emitter's unique id.

    Note: _emitterId can be set only once.

    Parameters

    emitter : Emitter

    An emitter for which id will be set.

    [ id ] : string

    Unique id to set. If not passed, random unique id will be set.

    Returns

    void