@lifaon/rx-js-light
Version:
Blazing fast Observables
28 lines (27 loc) • 829 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.debounceFrameObservable = void 0;
var create_animation_frame_1 = require("../../../../../../misc/timer/create-animation-frame.cjs");
function debounceFrameObservable(subscribe) {
return function (emit) {
var abortAnimationFrame = null;
var unsubscribe = subscribe(function (value) {
if (abortAnimationFrame !== null) {
abortAnimationFrame();
}
abortAnimationFrame = (0, create_animation_frame_1.createAnimationFrame)(function () {
abortAnimationFrame = null;
emit(value);
});
});
return function () {
unsubscribe();
if (abortAnimationFrame !== null) {
abortAnimationFrame();
}
};
};
}
exports.debounceFrameObservable = debounceFrameObservable;