RxPHP icon indicating copy to clipboard operation
RxPHP copied to clipboard

Allow merge/flatMap and variants to support arrays or iterator in addition to observables

Open davidwdan opened this issue 7 years ago • 1 comments

Example:

->flatMap(function(array $x){
    return $x;
})

davidwdan avatar May 19 '17 13:05 davidwdan

From the subject of this issue I guess you mean something like this, @davidwdan right?

$sequence = Observable::fromArray([[1,2], [3,4], [5,6]]);

$sequence
    ->flatMap(static fn (array $items) => Observable::fromArray($items))
    ->do(static fn (int $item) => $io->note(sprintf('Item: %d', $item)))
    ->subscribe();

// prints:
// Item: 1
// Item: 2
// Item: 3
// Item: 4
// Item: 5
// Item: 6

Is that what you are looking for? Otherwise could you provide a more verbose example?

makomweb avatar Feb 07 '23 13:02 makomweb