Generalize Effect Handling with Drivers in the run() Function

InstructorAndré Staltz

Share this video with your friends

Send Tweet

The last part of the code we wrote is neither logic nor effects. It is code which ties together logic (main) with effects. We can encapsulate that in a run() function. This lesson shows how we can structure these pieces together, and generalize effect handling with "drivers".

Samuel Sharpe
~ 9 years ago

If you comment out Log: from main(), it will still throw an error. I think run() would need to check the keys before running each effects https://jsbin.com/fahazihahe/1/edit?html,js,console,output?

André Staltzinstructor
~ 9 years ago

Samuel, correct! That if statement slipped from me when recording, and the program still executed. However, we quickly introduced the official Cycle.run(), which I mentioned has enough error checks. The point of this lesson is to understand what run() is responsible for.

Adam Barrett
~ 9 years ago

So close to calling it Log Driver https://www.youtube.com/watch?v=upsZZ2s3xv8 ...so close