Reputation: 11888
I have an array of objects Foo
:
let a, b, c = new Foo()
let l: Array<Foo> = [a, b, c]
evaluateFoo(f: Foo): boolean {
...
}
I am currently using a map
to basically convert my list of Foo
to an array of boolean
(with the evaluteFoo
function). Ultimately, what I want to get is either true
or false
--> either one of the evaluateFoo
functions return true
, or not, and I return false
.
Currently, to do so I am first doing : l.map(f => evaluateFoo(f)) and then I go true the new array and do the check to see if one of the value is true.
As you understood this is tedious for something quite easy. Any other rxjs operator that could help me having something simpler ?
Upvotes: 2
Views: 434
Reputation: 24541
Isn't that what you are looking for?
[1, 2, 3].some(e => e > 3)
> false
[1, 2, 3, 4].some(e => e > 3)
> true
where 1, 2, 3 are your Foo
s and e => e > 3
is your evaluation function
Upvotes: 2