Skip to content

Instantly share code, notes, and snippets.

@solatis
Created March 18, 2014 18:47
Show Gist options
  • Save solatis/9626735 to your computer and use it in GitHub Desktop.
Save solatis/9626735 to your computer and use it in GitHub Desktop.
/*
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