Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将代码从Angular/RXJS 4重写为6_Angular_Rxjs - Fatal编程技术网

将代码从Angular/RXJS 4重写为6

将代码从Angular/RXJS 4重写为6,angular,rxjs,Angular,Rxjs,我很难为angular 6重写这段代码。我的angular应用程序在RXJS库中经常出错。我甚至尝试安装Rxjs compat,但到目前为止,还没有解决任何问题 public publicar(): void { this.bd.publicar({ email: this.email, titulo: this.formulario.value.titulo, imagem: this.imagem[0] }) let acompa

我很难为angular 6重写这段代码。我的angular应用程序在RXJS库中经常出错。我甚至尝试安装Rxjs compat,但到目前为止,还没有解决任何问题

public publicar(): void {
    this.bd.publicar({
      email: this.email,
      titulo: this.formulario.value.titulo,
      imagem: this.imagem[0]
    })

    let acompanhamentoUpload = Observable.interval(1500)

    let continua = new Subject()

    continua.next(true)

    acompanhamentoUpload
      .takeUntil(continua)
      .subscribe(() => {
        //console.log(this.progresso.status)
        //console.log(this.progresso.estado)
        this.progressoPublicacao = 'andamento'

        this.porcentagemUpload = Math.round(( this.progresso.estado.bytesTransferred / this.progresso.estado.totalBytes ) * 100)

        if(this.progresso.status === 'concluido') {
          this.progressoPublicacao = 'concluido'
          //emitir um evento do componente parent (home)
          this.atualizarTimeLine.emit()
          continua.next(false)
        }
      })
  }

问题在于
.takeUntil(continua)
您必须将其更改为
.pipe(takeUntil(continua))
您还必须像以下那样导入它:

import { takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
您的代码如下所示:

public publicar(): void {
    this.bd.publicar({
      email: this.email,
      titulo: this.formulario.value.titulo,
      imagem: this.imagem[0]
    })

    let acompanhamentoUpload = Observable.interval(1500)

    let continua = new Subject()

    continua.next(true)

    acompanhamentoUpload
    .pipe(takeUntil(continua))
      .subscribe(() => {
        //console.log(this.progresso.status)
        //console.log(this.progresso.estado)
        this.progressoPublicacao = 'andamento'

        this.porcentagemUpload = Math.round(( this.progresso.estado.bytesTransferred / this.progresso.estado.totalBytes ) * 100)

        if(this.progresso.status === 'concluido') {
          this.progressoPublicacao = 'concluido'
          //emitir um evento do componente parent (home)
          this.atualizarTimeLine.emit()
          continua.next(false)
        }
      })
  }

完美的谢谢你帮助我!