RxJS ReplaySubject

2020-10-13 17:18 更新

主题的一种变体,可“重放”新的订阅用户或向新的订阅用户发出旧的值。它缓冲一定数量的值,除了向现有订阅用户发送新值外,还将立即将这些值发送给任何新订阅用户。

class ReplaySubject<T> extends Subject {
  constructor(bufferSize: number = Number.POSITIVE_INFINITY, windowTime: number = Number.POSITIVE_INFINITY, scheduler?: SchedulerLike)
  _subscribe(subscriber: Subscriber<T>): Subscription
  _getNow(): number

 
  // inherited from index/Subject
  static create: Function
  constructor()
  observers: Observer<T>[]
  closed: false
  isStopped: false
  hasError: false
  thrownError: any
  lift<R>(operator: Operator<T, R>): Observable<R>
  next(value?: T)
  error(err: any)
  complete()
  unsubscribe()
  _trySubscribe(subscriber: Subscriber<T>): TeardownLogic
  _subscribe(subscriber: Subscriber<T>): Subscription
  asObservable(): Observable<T>

 
  // inherited from index/Observable
  static create: Function
  static if: typeof iif
  static throw: typeof throwError
  constructor(subscribe?: (this: Observable<T>, subscriber: Subscriber<T>) => TeardownLogic)
  _isScalar: boolean
  source: Observable<any>
  operator: Operator<any, T>
  lift<R>(operator: Operator<T, R>): Observable<R>
  subscribe(observerOrNext?: NextObserver<T> | ErrorObserver<T> | CompletionObserver<T> | ((value: T) => void), error?: (error: any) => void, complete?: () => void): Subscription
  _trySubscribe(sink: Subscriber<T>): TeardownLogic
  forEach(next: (value: T) => void, promiseCtor?: PromiseConstructorLike): Promise<void>
  pipe(...operations: OperatorFunction<any, any>[]): Observable<any>
  toPromise(promiseCtor?: PromiseConstructorLike): Promise<T>
}

建设者

constructor(bufferSize: number = Number.POSITIVE_INFINITY, windowTime: number = Number.POSITIVE_INFINITY, scheduler?: SchedulerLike)

参量 类型
bufferSize 大小可选的。默认值为Number.POSITIVE_INFINITY。类型:number
windowTime 可选的。默认值为Number.POSITIVE_INFINITY。类型:number
调度器 可选的。默认值为undefined。类型:SchedulerLike

方法

订阅() _subscribe(subscriber: Subscriber<T>): Subscription

参量 类型
subscriber 类型:。Subscriber

returnsSubscription

_getNow()
_getNow(): number参量没有参数。returnsnumber
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号