https://github.com/masylum/i-love-async
"Slides" from the little talk I gave on the Barcelona nodejs meetup
https://github.com/masylum/i-love-async
Last synced: about 1 year ago
JSON representation
"Slides" from the little talk I gave on the Barcelona nodejs meetup
- Host: GitHub
- URL: https://github.com/masylum/i-love-async
- Owner: masylum
- Created: 2011-06-17T09:19:08.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2011-06-17T09:20:32.000Z (about 15 years ago)
- Last Synced: 2024-04-11T03:26:20.686Z (over 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 89.8 KB
- Stars: 14
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Async patterns
"I love async, but I can't code like this "
# Functional approach
Solving problems with imperative languages is done by defining "HOW"
do A, then do B, then you get C
Solving problems with functional languages is done by defining "WHAT"
C is what you get from B once you did A
Asynchronous code is not linear, so define your problems in a functional way if possible.
# Chain/Serial pattern
Do *n* asynchronous calls, one after each other.
Example:
get A from db, use A.id to get B from db, use B.id to get C
# Parallel pattern
Do *n* asynchronous calls, process them, and callback once we are done.
Example:
get A and B and do C when they are done