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
/** | |
* There's some pretty awesome low-level composition that you can do with async functions: | |
* Check out funcadelic! https://github.com/cowboyd/funcadelic.js | |
*/ | |
import { Functor, Semigroup, Monoid } from 'funcadelic'; | |
const AsyncFunction = (async function() {}).constructor; | |
/** | |
* It's a Functor! |
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
/** | |
* Implements an operation to fetch the data as described in https://twitter.com/BenLesh/status/1455597411385098242 | |
* The "winner" is unambiguous. It is the request corresponding to the latest click, guaranteed. | |
* Other important things to note: | |
* | |
* 1. The HTTP request is cancelled every time along with its containing task | |
* 2. click listener is removed automatically at the end of the `clickToLoad` operation | |
* 3. The cancellation logic is explicit here to demonstrate the concept, but it can easily be abstracted into a separate | |
*. function. See the `click-to-load-HOF` example below | |
*/ |
OlderNewer