PIXI.Runner

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

Constructor


new PIXI.Runner(name: string) → {}
Parameters:
Name Type Description
name string

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

Summary


Properties from Runner

boolean
empty
string
name

Methods from Runner

this
add(item: any)

Add a listener to the Runner

boolean
contains(item: any)
void
destroy()

Remove all references, don't use after this.

dispatch()
this
emit(params: any)
this
remove(item: any)
this
removeAll()

Remove all listeners from the Runner

run()

Public Properties


empty Runner.ts:174
empty: boolean

true if there are no this Runner contains no listeners

name Runner.ts:183
name: string

The name of the runner.

Public Methods


add Runner.ts:101
add(item: any) → {this}

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:
Name Type Description
item any

The object that will be listening.

Returns:
Type Description
this
contains Runner.ts:148
contains(item: any) → {boolean}

Check to see if the listener is already in the Runner

Parameters:
Name Type Description
item any

The listener that you would like to check.

Returns:
Type Description
boolean
destroy Runner.ts:166
destroy() → {void}

Remove all references, don't use after this.

Returns:
Type Description
void
dispatch Runner.ts:194
dispatch() → {}

Alias for emit

See: PIXI.Runner#emit
emit Runner.ts:62
emit(params: any) → {this}

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

Parameters:
Name Type Attributes Description
params any

<optional>

(optional) parameters to pass to each listener

Returns:
Type Description
this
remove Runner.ts:131
remove(item: any) → {this}

Remove a single listener from the dispatch queue.

Parameters:
Name Type Description
item any

The listener that you would like to remove.

Returns:
Type Description
this
removeAll Runner.ts:157
removeAll() → {this}

Remove all listeners from the Runner

Returns:
Type Description
this
run Runner.ts:201
run() → {}

Alias for emit

See: PIXI.Runner#emit

Powered by webdoc!