Skip to content

Instantly share code, notes, and snippets.

@shwoodard
Created July 6, 2012 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shwoodard/3060765 to your computer and use it in GitHub Desktop.
Save shwoodard/3060765 to your computer and use it in GitHub Desktop.
Some useful functions when developing ember apps
window.delay = (duration, toRun) ->
Ember.run.later(toRun, duration)
window.waitUntil = (context, interval, toRun, condition) ->
if condition.call(context)
return toRun.call(context)
delay interval, ->
waitUntil(context, interval, toRun, condition)
Ember.Object.reopenClass
createFromUnderscoreKeys: (options) ->
keys = $.makeArray(Ember.keys(options))
camelKeys = Ember.EnumerableUtils.map keys, (key) ->
key.camelize()
Ember.EnumerableUtils.forEach keys, (key, i) ->
options[camelKeys[i]] = options[key]
delete options[key]
Ember.Object.create(options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment