Created
June 16, 2020 12:01
-
-
Save afcastano/cb937a6d0746d665acf06aa08533ec6a to your computer and use it in GitHub Desktop.
Example on how to use IO.ts
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
const fetchUser: (id: string) => IO<User> = | |
id => new IO(effects => effects.findById(id)); | |
const notifyUser: (user: User) => IO<void> = | |
id => new IO(effects => effects.notify(user)); | |
const exampleFunc: (id: string) => IO<void> = _do(function* (id) { | |
const user: User = yield fetchUser(id); | |
yield notifyUser(user); | |
log.info('User has been notified') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment