diff --git a/Async/async.md b/Async/async.md new file mode 100644 index 00000000..f7764133 --- /dev/null +++ b/Async/async.md @@ -0,0 +1,20 @@ + + +
+The result of the calculation is:
+ + + + + + diff --git a/Async/callbacks.md b/Async/callbacks.md new file mode 100644 index 00000000..9096cbd7 --- /dev/null +++ b/Async/callbacks.md @@ -0,0 +1,31 @@ + + + + +JavaScript functions are executed in the sequence they are called.
+ + + + + + + + + diff --git a/Async/promises.md b/Async/promises.md new file mode 100644 index 00000000..94cba13c --- /dev/null +++ b/Async/promises.md @@ -0,0 +1,18 @@ +let myPromise = new Promise(function(myResolve, myReject) { +// "Producing Code" (May take some time) + + myResolve(); // when successful + myReject(); // when error +}); + +// "Consuming Code" (Must wait for a fulfilled Promise) +myPromise.then( + function(value) { /* code if successful */ }, + function(error) { /* code if some error */ } +); + +When the producing code obtains the result, it should call one of the two callbacks: + +When Call +Success myResolve(result value) +Error myReject(error object) \ No newline at end of file diff --git a/javascript-docs b/javascript-docs new file mode 160000 index 00000000..09593f9c --- /dev/null +++ b/javascript-docs @@ -0,0 +1 @@ +Subproject commit 09593f9ca9e396e383d1cdc49cf641ca9f0e9446