"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createBroadbandObservable = void 0;
const rxjs_1 = require("rxjs");
const BroadbandSubscriber_1 = require("../BroadbandSubscriber");
/**
 * Create an observable that listens to all partitions of a Streamr stream.
 *
 * @see BroadbandSubscriber
 */
const createBroadbandObservable = (client, stream) => {
    return new rxjs_1.Observable((observer) => {
        const subscriber = new BroadbandSubscriber_1.BroadbandSubscriber(client, stream);
        // Notifies the observer about new messages, as they arrive to the subscriber
        subscriber.subscribe((content, metadata) => {
            observer.next([content, metadata]);
        });
        // Triggers BroadbandSubscriber#unsubscribe when the observable is unsubscribed
        return () => {
            subscriber.unsubscribe();
        };
    });
};
exports.createBroadbandObservable = createBroadbandObservable;
//# sourceMappingURL=BroadbandObservable.js.map