Although this question may seem simple to a seasoned professional, I have struggled to wrap my head around it despite trying multiple approaches.
In my code, I have an observable observable1
that contains a list of keys like:
[
key1,
key3,
key4,
..
]
The second observable observable2
contains data with some keys from observable1
mapping to them. It looks something like:
[
{key1, val1},
{key2, val2},
{key3, val3},
{key4, val4},
..
]
Assuming each key in observable1
has a corresponding mapping in observable2
, I want to create a new observable observable3
that only emits the data mapped to by a key in observable1
.
Using the example provided, the expected output should omit the data for key2 and look like:
[
{key1, val1},
{key3, val3},
{key4, val4},
..
]
This result should be logged to the console after subscribing.
How can this functionality be achieved using rxjs? Just for your information, I am working with typescript.