Skip to content

Instantly share code, notes, and snippets.

@afcastano
Created June 16, 2020 12:01
Show Gist options
  • Save afcastano/cb937a6d0746d665acf06aa08533ec6a to your computer and use it in GitHub Desktop.
Save afcastano/cb937a6d0746d665acf06aa08533ec6a to your computer and use it in GitHub Desktop.
Example on how to use IO.ts
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