MENU

Fun & Interesting

Theo should use Effect

Ethan Niser 37,220 lượt xem 1 year ago
Video Not Working? Fix It Now

Thanks for watching!

Theo's Video: https://www.youtube.com/watch?v=f2Z1v3cqgDI

Live Example Site: https://theo-effect-promise.vercel.app/
Github Repo For This^^ Site: https://github.com/ethanniser/theo-effect-promise

My 30min "Effect For Beginners" Tutorial: https://www.youtube.com/watch?v=fTN8BX5qj6s
Effect Website/Docs: https://effect.website/

Thisweekinreact Seb's Tweet: https://twitter.com/sebastienlorber/status/1691510563162013696

Quick note about the semantics of "promise.all 'runs' all the promises you pass to it"

This isn't really how things work, promises execute on creation, promise.all is just awaiting all of their results at the same time. For the purposes of limiting concurrency, you want to delay this executation which is why in the async queue the input type is (function that returns promise)[], because by putting the creation of the promise behind a function call you can delay its execution.

TDLR it was a simplification I made for the video

FOLLOW ME ON TWITTER- https://twitter.com/ethanniser

VS Code:
Font - Fira Code
Theme - Material Theme Darker
Gear:
Microphone - Shure SM58
Headphones - Philips SHP9500
Interface - Focusrite Scarlett 2i2

Timestamps:
0:00 Intro
1:07 Two Ways to Handle Errors
2:08 Recapping Theo's Example
3:21 The Problem with Theo's Example
3:57 Effect.all over Promise.all
4:53 Converting Theo's Example to Effect
7:15 Collecting Errors in Effect with 'Either'
8:42 Maybe We Want to Short Circuit?
9:33 Basic Interruption
10:44 Effectful Interruption
11:34 Controlling Concurrency
12:39 Async is hard, Effect makes it better

Corrections:
11:42 Not exactly how things actually work, check description

Comment