Skip to content

Instantly share code, notes, and snippets.

Created August 11, 2015 07:43
Show Gist options
  • Save anonymous/d56ba89fad6bee040806 to your computer and use it in GitHub Desktop.
Save anonymous/d56ba89fad6bee040806 to your computer and use it in GitHub Desktop.
Promise then parallel code style // source https://jsbin.com/digaxa
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<meta charset="utf-8">
<title>Promise then parallel code style</title>
<style id="jsbin-css">
.demo{
color: red;
}
</style>
</head>
<body>
<div id="wrap">ccc</div>
<script id="jsbin-javascript">
var promise = Promise.resolve(jQuery("#wrap"));
promise
.then(function(el) {
el.html("<p>init</p>");
}
)
.then(function(el) {
el.addClass("demo");
})
.catch(function(e) {
console.log(e.message);
});
</script>
<script id="jsbin-source-css" type="text/css">.demo{
color: red;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">var promise = Promise.resolve(jQuery("#wrap"));
promise
.then(function(el) {
el.html("<p>init</p>");
}
)
.then(function(el) {
el.addClass("demo");
})
.catch(function(e) {
console.log(e.message);
});</script></body>
</html>
.demo{
color: red;
}
var promise = Promise.resolve(jQuery("#wrap"));
promise
.then(function(el) {
el.html("<p>init</p>");
}
)
.then(function(el) {
el.addClass("demo");
})
.catch(function(e) {
console.log(e.message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment