every
every({ predicate: Function, stores })
Motivation
The method calculates boolean value if each store satisfies the condition in predicate
.
It is useful to check that user has correct values in each state.
Formulae
$result
will betrue
if each callpredicate
on each store value fromvalues
returnstrue
, otherwise it will befalse
Arguments
predicate: (value: T) => boolean
— Function to check store valuestores: Array<Store<T>>
— List of stores
Return
$result: Store<boolean>
—true
if each store corresponds topredicate
Example
every({ predicate: value, stores })
Motivation
This overload compares each store to specific value in predicate
.
It is useful when you write combine
with &&
very often, for example to create a pending state or a form valid flag.
Formulae
$result
will betrue
if each value instores
equalsvalue
, otherwise it will befalse
Arguments
predicate
(T)
— Data to compare stores values withstores
(Array<Store<T>>)
— List of stores to compare withvalue
- type of
value
andstores
should be the same
Return
$result
(Store<boolean>)
—true
if each store containsvalue
Example
every({ predicate: Store, stores })
Motivation
This overload compares each store to specific value in the store predicate
.
It is useful when you write combine
with &&
very often, for example to create a pending state or a form valid flag.
Formulae
$result
will betrue
if each value instores
equals value in the$value
, otherwise it will befalse
Arguments
predicate
(Store<T>)
— Store contains value to compare values fromstores
withstores
(Array<Store<T>>)
— List of stores to compare with$value
store- type of
value
andstores
should be the same
Return
$result
(Store<boolean>)
—true
if each store contains value from thepredicate
store
Example
Shorthands
Shorthand have the same rules as the main overrides, just it uses positional arguments instead of object-form.
Arguments
stores
(Array<Store<T>>)
— List of stores to compare with predicate in the second argumentpredicate
(Store<T> | (value: T) => boolean | T)
— Predicate to compare with