Options
All
  • Public
  • Public/Protected
  • All
Menu

A Runner is a highly performant and simple alternative to signals. Best used in situations where events are dispatched to many objects at high frequency (say every frame!)

like a signal..

import { Runner } from '@pixi/runner';

const myObject = {
    loaded: new Runner('loaded')
}

const listener = {
    loaded: function(){
        // thin
    }
}

myObject.loaded.add(listener);

myObject.loaded.emit();

Or for handling calling the same function on many items

import { Runner } from '@pixi/runner';

const myGame = {
    update: new Runner('update')
}

const gameObject = {
    update: function(time){
        // update my gamey state
    }
}

myGame.update.add(gameObject);

myGame.update.emit(time);
memberof

PIXI

Hierarchy

  • Runner

Index

Constructors

constructor

  • new Runner(name: string): Runner
  • Parameters

    • name: string

      the function name that will be executed on the listeners added to this Runner.

    Returns Runner

Properties

Private _aliasCount

_aliasCount: any

Private _name

_name: any

Private ensureNonAliasedItems

ensureNonAliasedItems: any

items

items: any[]

Accessors

empty

  • get empty(): boolean
  • true if there are no this Runner contains no listeners

    member

    {boolean}

    readonly

    Returns boolean

name

  • get name(): string
  • The name of the runner.

    member

    {string}

    readonly

    Returns string

Methods

add

  • Add a listener to the Runner

    Runners do not need to have scope or functions passed to them. All that is required is to pass the listening object and ensure that it has contains a function that has the same name as the name provided to the Runner when it was created.

    Eg A listener passed to this Runner will require a 'complete' function.

    import { Runner } from '@pixi/runner';
    
    const complete = new Runner('complete');
    

    The scope used will be the object itself.

    Parameters

    • item: unknown

      The object that will be listening.

    Returns Runner

contains

  • contains(item: unknown): boolean
  • Check to see if the listener is already in the Runner

    Parameters

    • item: unknown

      The listener that you would like to check.

    Returns boolean

destroy

  • destroy(): void
  • Remove all references, don't use after this.

    Returns void

emit

  • emit(a0?: unknown, a1?: unknown, a2?: unknown, a3?: unknown, a4?: unknown, a5?: unknown, a6?: unknown, a7?: unknown): Runner
  • Dispatch/Broadcast Runner to all listeners added to the queue.

    Parameters

    • Optional a0: unknown
    • Optional a1: unknown
    • Optional a2: unknown
    • Optional a3: unknown
    • Optional a4: unknown
    • Optional a5: unknown
    • Optional a6: unknown
    • Optional a7: unknown

    Returns Runner

remove

  • remove(item: unknown): Runner
  • Remove a single listener from the dispatch queue.

    Parameters

    • item: unknown

      The listener that you would like to remove.

    Returns Runner

removeAll

  • Remove all listeners from the Runner

    Returns Runner

Generated using TypeDoc