If you know what PubSub means then you can achieve nearly the same behavior with the Subject(s) features of the RxJS. More details here, here and here.

Short demo (in Angular2):

import { Component, OnInit } from '@angular/core';
import {ReplaySubject} from 'rxjs/ReplaySubject';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
    //define the subject property in your class
    subject: ReplaySubject<any>;

    ngOnInit() {
        console.log('init');
        this.subject = new ReplaySubject(1); // get only the last message when there is a new subscriber

        let subscriber1 = this.subject.subscribe(function a(x) {
            console.log('1st subscriber: ' + x);
        });

        let subscriber2 = this.subject.subscribe(function b(x) {
            console.log('2nd subscriber: ' + x);
        });

        console.log('send/push the 1st message to subscribers');
        this.push('message 1');
        console.log('send/push the 2nd message to subscribers');
        this.push('message 2');

        console.log('add new subscriber. It should receive the last message pushed by the subject.');
        let subscriber3 = this.subject.subscribe(function b(x) {
            console.log('3rd subscriber: ' + x);
        });

        console.log('send/push the 3rd message to subscribers');
        this.push('message 3');

        console.log('remove the 2nd subscriber');
        subscriber2.unsubscribe();

        console.log('send/push the 4th message to subscribers');
        this.push('message 4');
    }

    push(something) {
        this.subject.next(something);
    }
}

Result:

init

send/push the 1st message to subscribers
1st subscriber: message 1
2nd subscriber: message 1

send/push the 2nd message to subscribers
1st subscriber: message 2
2nd subscriber: message 2

add new subscriber. It should receive the last message pushed by the subject.
3rd subscriber: message 2

send/push the 3rd message to subscribers
1st subscriber: message 3
2nd subscriber: message 3
3rd subscriber: message 3

remove the 2nd subscriber
send/push the 4th message to subscribers
1st subscriber: message 4
3rd subscriber: message 4

Please don’t forget that in RxJS5 dispose() has been ‘replaced’ by unsubscribe(). More details here.
Something similar for Observable can be achieved using the shareReplay(1). The shareReplay() has been replaced by publishReplay().refCount()

The same behavior using publishReplay().refCount()


import { Component, OnInit } from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observer} from 'rxjs/Observer';
import 'rxjs/Rx';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
    observable:Observable<any>;
    observer:Observer<any>;


    ngOnInit() {
        console.log('init');

        let subscriber1 = this.getObserver();
        subscriber1.subscribe((response) => {
            console.log('subscriber1 fired!', response);
        });

        let subscriber2 = this.getObserver();
        subscriber2.subscribe((response) => {
            console.log('subscriber2 fired!', response);
        });

        setTimeout(() => {
            console.log('push 2nd message to subscribers with 4 second delay');
            this.observer.next('2nd message');
        }, 4000);

        setTimeout(()=>{
            console.log('3rd subscribers subscribes after 6 seconds');
            let subscriber3 = this.getObserver();
            subscriber3.subscribe((response) => {
                console.log('subscriber3 fired!', response);
            });
        }, 6000);
    }

    getObserver():Observable<any> {
        if(!this.observable) {
            this.observable = new Observable( (observer) => {
                this.observer = observer;
                console.log('Observer initialized');
                this.observer.next('1st message');
            } ).publishReplay(1).refCount(); // 1 - the new subscribers will receive only last pushed data
            // if you remove the number 1 then the new subscribers will receive all the data pushed by the Observable previously
        }

        return this.observable;
    }
}

Result:


init
Observer initialized
subscriber1 fired! 1st message
subscriber2 fired! 1st message

push 2nd message to subscribers with 4 second delay
subscriber1 fired! 2nd message
subscriber2 fired! 2nd message

3rd subscribers subscribes after 6 seconds
subscriber3 fired! 2nd message