Created
July 7, 2014 00:34
-
-
Save PatrickJS/edecde38f7f530364556 to your computer and use it in GitHub Desktop.
Polling for row updates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
I been looking for this example, thanks for posting, but Can you explain how this works. I mean, how I can fetch api data or huge list of data and put it on scroll...?
I'm also bid confused on how it will take rowHides and rowShow? is there event for that?