The pluck
function in rxjs is used to extract a specific property (or nested property) from each source object in a stream of data. Here's an example of how to use pluck
:
index.tsx635 chars21 lines
In this example, we create an observable source$
from an array of data. We then use the pluck
operator to extract the "name" property from each object in the source$
stream, and also extract the "id" and "age" properties from each object. Finally, we subscribe to the resulting streams (name$
and idAge$
) to see the extracted values.
gistlibby LogSnag