Class: EventRegistry<EventType>

Type parameters

Name
EventType

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new EventRegistry<EventType>(scope?)

Type parameters

Name
EventType

Parameters

Name Type
scope? Scope

Properties

emitOnce

Readonly emitOnce: (event: EventType) => void

Type declaration

(event): void

Parameters
Name Type
event EventType
Returns

void


emitter

Private Readonly emitter: any


generatorFactory

Private generatorFactory: any

这个方法用于将事件转换为异步迭代器


scope

Readonly scope: Scope

Implementation of

Scoped.scope

Methods

[scopeDisposeSymbol]

[scopeDisposeSymbol](): void

Returns

void

Implementation of

Scoped.[scopeDisposeSymbol]


listen

listen(...disposers): AsyncGenerator<Awaited<EventType>, void, unknown>

监听事件

这个方法可以将事件以流的方式返回,当scope销毁时,这个方法会自动退出

同时,这个方法也支持传入其它的disposer,当disposer中的任意一个触发时,这个方法也会退出

Parameters

Name Type
...disposers (Scope | AbortSignal | Promise<void>)[]

Returns

AsyncGenerator<Awaited<EventType>, void, unknown>

Argument

disposers 可以传入Promise、AbortSignal、Scope实例


registry

registry(register): () => void

增加绑定事件

Parameters

Name Type
register EventSourceRegister<EventType>

Returns

fn

(): void

增加绑定事件

Returns

void