Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

165
Visualizações
modify Observable in Angular and return new Observable with made changes

I have a this Observable

obs1$ = this.otherService.getObservable() which is of type number

I want to create a method which emits a Observable using the return value of this Observable


 combined() {
    this.currentLambdaReactorState$.subscribe((e) => {
      let dto = of([
        {
          name: 'foo',
          value: e,
        },
      ])
        return dto
    });
  }


so far this method does not return anything, how can I return a Observable from that method ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Map is what you want here.

// replace any with your type (returned from currentLambdaReactorState$)
combined(): Observable<{name: string, value: any}> {
  return this.currentLambdaReactorState$.pipe(
    // shorthand object literal return
    map((e)=> ({name: 'foo', value: e})) 
  )
}

// usage
combined().subscribe((mappedValue) => {
  console.log(mappedValue); // {name: 'foo', value: e}
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda