Created
August 11, 2015 07:43
-
-
Save anonymous/d56ba89fad6bee040806 to your computer and use it in GitHub Desktop.
Promise then parallel code style // source https://jsbin.com/digaxa
This file contains hidden or 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
| <!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> |
This file contains hidden or 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
| .demo{ | |
| color: red; | |
| } |
This file contains hidden or 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
| 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