Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / src/public-api / AsyncCoordinator

Interface: AsyncCoordinator<T>

Defined in: projects/libraries/streamix/src/lib/utils/coordinator.ts:45

An async iterator that coordinates multiple sources.

Supports dynamic source management and both sync and async draining.

Extends

Type Parameters

T

T

The type of value emitted by the sources.

Properties

__tryNext()?

optional __tryNext: () => IteratorResult<RunnerEvent<T>, any> | null

Defined in: projects/libraries/streamix/src/lib/utils/coordinator.ts:50

Synchronously drain all available values from all sources (if supported). Returns DONE if all sources are complete, otherwise null if no values are available.

Returns

IteratorResult<RunnerEvent<T>, any> | null


__hasBufferedValues()?

optional __hasBufferedValues: () => boolean

Defined in: projects/libraries/streamix/src/lib/utils/coordinator.ts:55

Returns true if there are buffered values or all sources are done.

Returns

boolean

Methods

addSource()

addSource(source, key?): number

Defined in: projects/libraries/streamix/src/lib/utils/coordinator.ts:63

Dynamically add a new source to the coordinator.

Parameters

source

AsyncIterator<T>

The async iterator to add.

key?

any

Optional key used to remove the source by reference later.

Returns

number

The index assigned to the new source.


removeSource()

removeSource(index): Promise<void>

Defined in: projects/libraries/streamix/src/lib/utils/coordinator.ts:69

Remove a source from the coordinator and clean it up.

Parameters

index

number

The index of the source to remove.

Returns

Promise<void>


removeSourceByKey()

removeSourceByKey(key): Promise<void>

Defined in: projects/libraries/streamix/src/lib/utils/coordinator.ts:75

Remove a source by the key passed to addSource.

Parameters

key

any

The key of the source to remove.

Returns

Promise<void>


batch()

batch(callback): void

Defined in: projects/libraries/streamix/src/lib/utils/coordinator.ts:82

Batch multiple source additions/removals and emit a single notification after the batch completes.

Parameters

callback

() => void

Function that performs source changes.

Returns

void


getActiveSourceCount()

getActiveSourceCount(): number

Defined in: projects/libraries/streamix/src/lib/utils/coordinator.ts:88

Get the number of currently active (non-completed, non-removed) sources.

Returns

number

The count of active sources.


isSourceComplete()

isSourceComplete(index): boolean

Defined in: projects/libraries/streamix/src/lib/utils/coordinator.ts:95

Check if a specific source is completed or removed.

Parameters

index

number

The source index to check.

Returns

boolean

True if the source is completed or removed, false otherwise.


next()

next(...__namedParameters): Promise<IteratorResult<RunnerEvent<T>, any>>

Defined in: node_modules/typescript/lib/lib.es2018.asynciterable.d.ts:32

Parameters

__namedParameters

[] | [any]

Returns

Promise<IteratorResult<RunnerEvent<T>, any>>

Inherited from

AsyncIterator.next


return()?

optional return(value?): Promise<IteratorResult<RunnerEvent<T>, any>>

Defined in: node_modules/typescript/lib/lib.es2018.asynciterable.d.ts:33

Parameters

value?

any

Returns

Promise<IteratorResult<RunnerEvent<T>, any>>

Inherited from

AsyncIterator.return


throw()?

optional throw(e?): Promise<IteratorResult<RunnerEvent<T>, any>>

Defined in: node_modules/typescript/lib/lib.es2018.asynciterable.d.ts:34

Parameters

e?

any

Returns

Promise<IteratorResult<RunnerEvent<T>, any>>

Inherited from

AsyncIterator.throw

Released under the GNU AGPL v3 or later.