Skip to content

@pumpkin-plugins/bedrock-addon-manager API / platform/handlers / HandlerRegistry

Class: HandlerRegistry<F> ​

Defined in: tools/plugin-kit/src/handlers.ts:5

Hands out ids for callbacks the host calls back by number. The API package's own base class does this too, but with ids and maps we can't reach, so this plugin keeps its own range.

Type Parameters ​

F ​

F

Constructors ​

Constructor ​

new HandlerRegistry<F>(firstId): HandlerRegistry<F>

Defined in: tools/plugin-kit/src/handlers.ts:10

Creates a registry whose ids start at firstId.

Parameters ​

firstId ​

number

Returns ​

HandlerRegistry<F>

Methods ​

add() ​

add(handler): number

Defined in: tools/plugin-kit/src/handlers.ts:22

Registers a handler.

Parameters ​

handler ​

F

The callback.

Returns ​

number

Its id.


get() ​

get(id): F | undefined

Defined in: tools/plugin-kit/src/handlers.ts:34

Looks a handler up.

Parameters ​

id ​

number

An id from add.

Returns ​

F | undefined

The handler, or undefined when the id isn't ours.


take() ​

take(id): F | undefined

Defined in: tools/plugin-kit/src/handlers.ts:39

Removes and returns a handler by id.

Parameters ​

id ​

number

Returns ​

F | undefined

Pumpkin Plugins documentation