axax
Version:
A library of async iterator extensions for JavaScript including ```map```, ```reduce```, ```filter```, ```flatMap```, ```pipe``` and [more](https://github.com/jamiemccrindle/axax/blob/master/docs/API.md#functions).
14 lines (13 loc) • 447 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const subject_1 = require("./subject");
function fromEvent(source, type) {
const subject = new subject_1.Subject();
const callback = (event) => {
subject.onNext(event);
};
source.addEventListener(type, callback);
subject.finally(() => source.removeEventListener(type, callback));
return subject.iterator;
}
exports.fromEvent = fromEvent;