Home Reference Source Repository
import {ReplaySubject} from 'rxstream/src/subjects/replaySubject.js'
public class | source

ReplaySubject

Extends:

Subject → ReplaySubject

ReplaySubject extends Subject. As Subject is a stream of values, ReplaySubject is also a stream, but a little bit different. The difference is that ReplaySubject remembers all values that's been sent to it, and it sends all these values to new subscribers. Take a look at example.

Example:

import { ReplaySubject } from 'rxstream';

let stream$ = new ReplaySubject();
stream$.next(1);
stream$.next(2);

stream$.subscribe(value => console.log(value));
stream$.next(3);
stream$.next(4);

// Output is going ot be: 1,2,3,4

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

calls: *[]

Method Summary

Public Methods
public

next(data: any)

Send value to the stream

public

Subscribe to the stream

Inherited Summary

From class Subject
public

next(data: any)

Send value to the stream

public

Subscribe to the stream

public

subscriptionList(subscriptionList: *): *

public

unsubscribe(subscription: Subscription)

Unsubscribe from the stream

Public Constructors

public constructor() source

Override:

Subject#constructor

Public Members

public calls: *[] source

Public Methods

public next(data: any) source

Send value to the stream

Override:

Subject#next

Params:

NameTypeAttributeDescription
data any

Any value

public subscribe(callback: function): Subscription source

Subscribe to the stream

Override:

Subject#subscribe

Params:

NameTypeAttributeDescription
callback function

Return:

Subscription