RxJS ReplaySubject

2020-10-13 17:18 更新

主題的一種變體,可“重放”新的訂閱用戶或向新的訂閱用戶發(fā)出舊的值。它緩沖一定數(shù)量的值,除了向現(xiàn)有訂閱用戶發(fā)送新值外,還將立即將這些值發(fā)送給任何新訂閱用戶。

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>
}

建設(shè)者

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

參量 類型
bufferSize 大小可選的。默認(rèn)值為Number.POSITIVE_INFINITY。類型:number。
windowTime 可選的。默認(rèn)值為Number.POSITIVE_INFINITY。類型:number
調(diào)度器 可選的。默認(rèn)值為undefined。類型:SchedulerLike

方法

訂閱() _subscribe(subscriber: Subscriber<T>): Subscription

參量 類型
subscriber 類型:。Subscriber

returnsSubscription

_getNow()
_getNow(): number參量沒有參數(shù)。returnsnumber
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)