Following up on the idea of "Rxjs can be used for everything" (and while not saying it should) I'd like to process arrays with Rxjs instead of array functions in React.
I tried different approaches (with different subscribe(), rxjs-hook, ...) but it didn't leave anywhere. Therefore I skip my wrong-doing and provide a simplified example.
Here's what I can do with array functions (map for simplicity):
const externalData = [1,2,3,4,5];
const App = () => {
const transformedData = externalData.map(i => `${i} was processed`)
return <>{transfomedData.join(", ")</>
}
How would I implement the same with rxjs?
// wrong approach
const externalData = [1,2,3,4,5];
const App = () => {
const transformedData = from(externalData).pipe(map(i => `${i} was processed`))
return <>{transfomedData.join(", ")</> // transformedData is Observable, not array
}