matchChange
matchChange<
E
,Type
,From
,To
>(changeEvent
:E
, …rest
: [Type
,From
|From
[],To
|To
[]] | [FlatFilters
<ChangeEventKeys
<E
>> & {type?
:Type
;from?
:From
|From
[];to?
:To
|To
[]; }]):changeEvent is E & HasFilterValues<E, { type: Type; to: { key: To }; from: { key: From } }>
Defined in: match-change.ts:24
Checks if a state change event matches the given type, from, and to keys. Accepts either a tuple of [type, from, to] or a filter object. Returns true if all specified keys match the event’s properties.
Type Parameters
Section titled “Type Parameters”Type Parameter | Default type | Description |
---|---|---|
E extends StateChangeEvent | - | State change event type |
Type extends undefined | string | FlatFilters <ChangeEventKeys <E >>["type" ] | Event type key |
From extends undefined | string | FlatFilters <ChangeEventKeys <E >>["from" ] | From state key |
To extends undefined | string | FlatFilters <ChangeEventKeys <E >>["to" ] | To state key |
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
changeEvent | E | The event to test. |
…rest | [Type , From | From [], To | To []] | [FlatFilters <ChangeEventKeys <E >> & { type? : Type ; from? : From | From []; to? : To | To []; }] | Tuple or filter object specifying type, from, and to keys. |
Returns
Section titled “Returns”changeEvent is E & HasFilterValues<E, { type: Type; to: { key: To }; from: { key: From } }>
True if the event matches all filter criteria.
Example
Section titled “Example”matchChange(event, "reject", "Pending", "Rejected");matchChange(event, { type: "resolve", from: "Pending", to: "Resolved" });