Skip to content

Instantly share code, notes, and snippets.

@iBasit
Forked from PatrickJS/polling-for-row-updates.js
Created February 22, 2016 01:20
Show Gist options
  • Save iBasit/8ceef1db9de945a37559 to your computer and use it in GitHub Desktop.
Save iBasit/8ceef1db9de945a37559 to your computer and use it in GitHub Desktop.
Polling for row updates
function getRowUpdates(row) {
var scrolls = Rx.Observable.fromEvent(document, 'scroll');
var rowVisibilities =
scrolls.throttle(50)
.map(function(scrollEvent) {
return row.isVisible(scrollEvent.offset);
})
.distinctUntilChanged();
var rowShows = rowrowVisibilities.filter(function(v) {
return v;
});
var rowHides = rowrowVisibilities.filter(function(v) {
return !v;
});
return rowShows
.flatMap(Rx.Observable.interval(10))
.flatMap(function() {
return row.getRowData().takeUntil(rowHides);
})
.toArray();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment