Skip to content

Instantly share code, notes, and snippets.

@mirzu
Last active December 18, 2015 18:49
Show Gist options
  • Select an option

  • Save mirzu/5828092 to your computer and use it in GitHub Desktop.

Select an option

Save mirzu/5828092 to your computer and use it in GitHub Desktop.
images emmiter
setInterval(function newImages() {
// TODO (bonus) - fetch images from flickr or other feeds and refresh the
// client with the fetched content.
images('http://api.flickr.com/services/feeds/photos_public.gne?format=json&tags=badcamp&nojsoncallback=1', function(err, data) {
var newImagesAry = [];
data = JSON.parse(data);
data.items.forEach(function eachItem(item) {
newImagesAry.push({
picture: item.media.m,
link: item.link
});
});
io.sockets.emit('newImages', newImagesAry);
});
}, config.pollInterval || 10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment