Class: Runner

PIXI.Runner

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);

new PIXI.Runner (name)

Runner.ts:52
Name Type Description
name string

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

Members

empty boolean readonly

true if there are no this Runner contains no listeners

name string readonly

The name of the runner.

Methods

add (item) PIXI.Runner

Runner.ts:101

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.

Name Type Description
item any

The object that will be listening.

Returns:
Type Description
PIXI.Runner

contains (item) boolean

Runner.ts:151

Check to see if the listener is already in the Runner

Name Type Description
item any

The listener that you would like to check.

Returns:
Type Description
boolean

destroy () void

Runner.ts:172

Remove all references, don't use after this.

dispatch

Runner.ts:206

Alias for emit

See:

emit (params) PIXI.Runner

Runner.ts:62

Dispatch/Broadcast Runner to all listeners added to the queue.

Name Type Attributes Description
params any <optional>

optional parameters to pass to each listener

Returns:
Type Description
PIXI.Runner

remove (item) PIXI.Runner

Runner.ts:133

Remove a single listener from the dispatch queue.

Name Type Description
item any

The listener that you would like to remove.

Returns:
Type Description
PIXI.Runner

removeAll () PIXI.Runner

Runner.ts:160

Remove all listeners from the Runner

Returns:
Type Description
PIXI.Runner

run

Runner.ts:213

Alias for emit

See: