Created
March 18, 2014 18:47
-
-
Save solatis/9626735 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
There once was a server-side stream eating function which looked like this: | |
*/ | |
Meteor.startup(-> | |
Crawler.Stream.create(sources).on('readable', -> | |
stream = this | |
while item = stream.read() | |
/* | |
And this is where things go wrong: although Fibers allow async | |
programming in a sync-style, it means execution is halted here | |
and the next item is only read after store()'s async operations | |
are completed. | |
*/ | |
store(item))) | |
/* | |
And our store() function has a collection update | |
*/ | |
store = (item) -> | |
MyCollection.upsert(item) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment