John Abraham
John Abraham

Reputation: 18781

Select and map over the values inside an observable

I am trying to select and map the values of an observable w/o subscription?

Question:

What are the operators to select doggo[documents] and map out blocks w/o breaking the Observable?

from:

this.doggos.getDoggos().subscribe((doggos) => {
      this.galleryItems = doggos['documents'].map(d => d.blocks);
    });

to:

this.galleryItemsObs  = this.doggos.getDoggos().pipe(...);

Upvotes: 1

Views: 226

Answers (1)

Harry Ninh
Harry Ninh

Reputation: 16728

Use map!

this.doggos.getDoggos().map((doggos) => {
  return doggos['documents'].map(d => d.blocks);
});

Upvotes: 3

Related Questions