小编mac*_*tyr的帖子

如何说服打字稿可以在主题上调用Observable运算符?

使用Angular 4.1.3,rxjs 5.3.0,打字稿2.2.2的示例代码:

import { Subject } from 'rxjs'

export class Example {
  public response$: Subject<boolean>;

  public confirm(prompt: string): Subject<boolean> {
    // ...set up a confirmation dialog...
    this.response$ = new Subject<boolean>();
    return this.response$.first();
  }
}
Run Code Online (Sandbox Code Playgroud)

当我尝试编译此代码时,打字稿抱怨最后一行:

The 'this' context of type 'Subject<boolean>' is not assignable to method's 'this' of type 'Observable<boolean>'.
  Types of property 'lift' are incompatible.
    Type '<R>(operator: Operator<boolean, R>) => Observable<boolean>' is not assignable to type '<R>(operator: Operator<boolean, R>) => Observable<R>'.
  Type 'Observable<boolean>' is not assignable to type …
Run Code Online (Sandbox Code Playgroud)

rxjs typescript rxjs5 angular

5
推荐指数
1
解决办法
273
查看次数

如何将命令行参数传递给服务容器?

我正在尝试设置一个使用 docker 容器提供的数据库服务的 bitbucket 管道。但是,为了正确启动数据库服务,我需要传递一个参数以供数据库容器的 ENTRYPOINT 接收。我从管道服务文档中看到,可以发送variables到服务的 docker 容器,但我需要设置的选项不能通过环境变量设置,只能通过命令行参数设置。

当我使用本地运行数据库的 docker 映像时docker run,我只需将其添加到命令末尾即可设置该选项docker run,并且它会正确应用于容器的 ENTRYPOINT,所以看起来这应该很简单,我可以不知道将参数放在 bitbucket-pipelines.yml 中的位置。

下面是我的 bitbucket-pipelines.yml。除了我需要一种将命令行参数传递到文件末尾的 victoria-metrics 容器之外,它的一切都很好。

image: node:14.16.1
pipelines:
  default:
    - step:
        caches:
          - node
        script:
          - npm install
          - npm test
        services:
          - mongo
          - victoriaMetrics

definitions:
  services:
    mongo:
      image: mongo:3.6
    victoriaMetrics:
      image: victoriametrics/victoria-metrics:v1.75.1
Run Code Online (Sandbox Code Playgroud)

bitbucket-pipelines

5
推荐指数
1
解决办法
1803
查看次数

标签 统计

angular ×1

bitbucket-pipelines ×1

rxjs ×1

rxjs5 ×1

typescript ×1