Skip to content

Instantly share code, notes, and snippets.

@maxbeatty
Created June 14, 2013 01:16
Show Gist options
  • Save maxbeatty/5778738 to your computer and use it in GitHub Desktop.
Save maxbeatty/5778738 to your computer and use it in GitHub Desktop.
dumb promises
$.get "/path", (data) =>
if data.length > 0
items = []
done = 0
for d in data
done++
require ["#{d.file}.html"], (tpl) ->
items.push
title: 'hmm'
partial: _.template tpl, d.tplData
done--
setTimeout =>
@render content: @wrapper items: items if done is 0
, 50
@maxbeatty
Copy link
Author

How could I have used Promises given require may or may not have had to make a request for the file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment