I
I
iluxa18102019-03-25 13:51:22
Angular
iluxa1810, 2019-03-25 13:51:22

How to get Observable from outside?

In general, there is such code:

getLastVersionData(assemblyId: number) {
    return this.getLastVersion(assemblyId).subscribe(result => {
      var version = <Version>result;
      return this.getFileByVersion(version.id);
    });
  }

I want to subscribe from the outside and get the result that the getFileByVersion function returns, but I can't do it because the Subscription is returned.
What can I do to return the Observable I need?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dasha Tsiklauri, 2019-03-25
@dasha_programmist

you have to write

this.getLastVersion(assemblyId).flatMap(result => {
      var version = <Version>result;
      return this.getFileByVersion(version.id);
    }).subscribe(result=>{});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question