Created
September 16, 2011 08:55
-
-
Save jensarps/1221611 to your computer and use it in GitHub Desktop.
EmbedJS code examples
This file contains 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
// DOM node creation quick'n'easy: | |
var containerNode = embed.create('div', { | |
className: 'container box', | |
innerHTML: '<span>Huh, a container!</span>', | |
style: { | |
border: 'solid red 1px' | |
} | |
}, parentNode); |
This file contains 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
// Async made easy – CommonJS compliant Promises with EmbedJS: | |
var doAsyncOperation = function(){ | |
var promise = new embed.Promise(); | |
setTimeout(function(){ // simulate some asnyc operation… | |
if(operationWasSuccessful) { | |
promise.resolve(someResult); | |
}else { | |
promise.reject(someError); | |
} | |
}, 500); | |
return promise; | |
} | |
// And use it like this: | |
doAsyncOperation().then(onSuccessCallback, onErrorCallback); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment