Skip to content

@sqlrooms/mosaic / Selection

Class: Selection

Represents a dynamic set of query filter predicates.

Extends

  • Param<SelectionClauseArray>

Constructors

Constructor

new Selection(resolver?, include?): Selection

Create a new Selection instance.

Parameters

ParameterTypeDescription
resolver?SelectionResolverThe selection resolution strategy to apply.
include?Selection[]Upstream selections whose clauses should be included as part of this selection. Any clauses published to these upstream selections will be relayed to this selection.

Returns

Selection

Overrides

Param.constructor

Properties

PropertyModifierTypeInherited from
_value?protectedSelectionClauseArrayParam._value
_resolvedpublicSelectionClauseArray-
_resolverpublicSelectionResolver-
_relaypublicSet<Selection>-
_callbackspublicMap<string, DispatchEntry<SelectionClauseArray>>Param._callbacks

Accessors

resolver

Get Signature

get resolver(): SelectionResolver

The selection clause resolver.

Returns

SelectionResolver


single

Get Signature

get single(): boolean

Indicate if this selection has a single resolution strategy.

Returns

boolean


clauses

Get Signature

get clauses(): SelectionClauseArray

The current array of selection clauses.

Returns

SelectionClauseArray


active

Get Signature

get active(): SelectionClause

The current active (most recently updated) selection clause.

Returns

SelectionClause


value

Get Signature

get value(): unknown

The value corresponding to the current active selection clause. This method ensures compatibility where a normal Param is expected.

Returns

unknown

Overrides

Param.value

Methods

value()

static value<T>(value): Param<T>

Create a new Param instance with the given initial value.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
valueTThe initial value of the Param.

Returns

Param<T>

The new Param instance.

Inherited from

Param.value


array()

static array<T>(values): Param<T[]>

Create a new Param instance over an array of initial values, which may contain nested Params.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
values(T | Param<T>)[]The initial values of the Param.

Returns

Param<T[]>

The new Param instance.

Inherited from

Param.array


intersect()

static intersect(options?): Selection

Create a new Selection instance with an intersect (conjunction) resolution strategy.

Parameters

ParameterTypeDescription
options?SelectionOptionsThe selection options.

Returns

Selection

The new Selection instance.


union()

static union(options?): Selection

Create a new Selection instance with a union (disjunction) resolution strategy.

Parameters

ParameterTypeDescription
options?SelectionOptionsThe selection options.

Returns

Selection

The new Selection instance.


single()

static single(options?): Selection

Create a new Selection instance with a singular resolution strategy that keeps only the most recent selection clause.

Parameters

ParameterTypeDescription
options?SelectionOptionsThe selection options.

Returns

Selection

The new Selection instance.


crossfilter()

static crossfilter(options?): Selection

Create a new Selection instance with a cross-filtered intersect resolution strategy.

Parameters

ParameterTypeDescription
options?Omit<SelectionOptions, "cross">The selection options.

Returns

Selection

The new Selection instance.


clone()

clone(): Selection

Create a cloned copy of this Selection instance.

Returns

Selection

A clone of this selection.


remove()

remove(source): Selection

Create a clone of this Selection with clauses corresponding to the provided source removed.

Parameters

ParameterTypeDescription
sourceClauseSourceThe clause source to remove.

Returns

Selection

A cloned and updated Selection.


valueFor()

valueFor(source): unknown

The value corresponding to a given source. Returns undefined if this selection does not include a clause from this source.

Parameters

ParameterTypeDescription
sourceunknownThe clause source to look up the value for.

Returns

unknown


activate()

activate(clause): void

Emit an activate event with the given selection clause.

Parameters

ParameterTypeDescription
clauseSelectionClauseThe clause representing the potential activation.

Returns

void


update()

update(clause): this

Update the selection with a new selection clause.

Parameters

ParameterTypeDescription
clauseSelectionClauseThe selection clause to add.

Returns

this

This Selection instance.

Overrides

Param.update


reset()

reset(clauses?): this

Reset the selection state by removing all provided clauses. If no clause array is provided as an argument, all current clauses are removed. The reset method (if defined) is invoked on all corresponding clause sources. The reset is relayed to downstream selections that include this selection.

Parameters

ParameterTypeDescription
clauses?SelectionClause[]The clauses to remove. If unspecified, all current clauses are removed.

Returns

this

This selection instance.


willEmit()

willEmit(type, value): unknown

Upon value-typed updates, sets the current clause list to the input value and returns the active clause value.

Parameters

ParameterTypeDescription
typestringThe event type.
valueunknownThe input event value.

Returns

unknown

For value-typed events, returns the active clause values. Otherwise returns the input event value as-is.

Overrides

Param.willEmit


emitQueueFilter()

emitQueueFilter(type, value): (value) => boolean | null

Upon value-typed updates, returns a dispatch queue filter function. The return value depends on the selection resolution strategy.

Parameters

ParameterTypeDescription
typestringThe event type.
valueSelectionClauseArrayThe new event value that will be enqueued.

Returns

(value) => boolean | null

A dispatch queue filter function. For non-value events, returns a function that always returns null (no filtering).

Overrides

Param.emitQueueFilter


skip()

skip(client, clause): boolean

Indicates if a selection clause should not be applied to a given client. The return value depends on the selection resolution strategy.

Parameters

ParameterTypeDescription
clientMosaicClient | null | undefinedThe client to test. If null or undefined, return false.
clauseSelectionClauseThe selection clause.

Returns

boolean

True if the client should be skipped, false otherwise.


predicate()

predicate(client?, noSkip?): ResolvedPredicate

Return a selection query predicate for the given client.

Parameters

ParameterTypeDescription
client?MosaicClient | nullThe client whose data may be filtered. If null or undefined, return a predicate with all clauses.
noSkip?booleanDisable skipping of active cross-filtered sources. If set true, the source of the active clause in a cross-filtered selection will not be skipped.

Returns

ResolvedPredicate

The query predicate for filtering client data, based on the current state of this selection.


addEventListener()

addEventListener(type, callback): void

Add an event listener callback for the provided event type.

Parameters

ParameterTypeDescription
typestringThe event type.
callbackEventCallback<SelectionClauseArray>The event handler callback function to add. If the callback has already been added for the event type, this method has no effect.

Returns

void

Inherited from

Param.addEventListener


removeEventListener()

removeEventListener(type, callback): void

Remove an event listener callback for the provided event type.

Parameters

ParameterTypeDescription
typestringThe event type.
callbackEventCallback<SelectionClauseArray>The event handler callback function to remove.

Returns

void

Inherited from

Param.removeEventListener


cancel()

cancel(type): void

Cancel all unemitted event values for the given event type.

Parameters

ParameterTypeDescription
typestringThe event type.

Returns

void

Inherited from

Param.cancel


pending()

pending(type): Promise<void>

Returns a promise that resolves when unknown pending updates complete for the event of the given type currently being processed. The Promise will resolve immediately if the queue for the given event type is empty.

Parameters

ParameterTypeDescription
typestringThe event type to wait for.

Returns

Promise<void>

A pending event promise.

Inherited from

Param.pending


emit()

emit(type, value): void

Emit an event value to listeners for the given event type. If a previous emit has not yet resolved, the event value will be queued to be emitted later. The actual event value given to listeners will be the result of passing the input value through the emitValue() method.

Parameters

ParameterTypeDescription
typestringThe event type.
valueSelectionClauseArrayThe event value.

Returns

void

Inherited from

Param.emit