You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both of our Cohort 2 trainees have raised existential questions around Context. We may want to find some useful references or write up some material about this.
We may even want to make a "implement WithTimeout using WithValue" exercise to show that there's no magic here, it's really just a fancy key-value store.
(I've also gone on a tangent around persistent data structures when talking through this, unclear whether that's actually useful/worthwhile :))
The text was updated successfully, but these errors were encountered:
The journey I've typically used to explain this is:
We know about dependency injection, when people take dependency injection to extremes they end up with too many parameters, they often extract a context object to contain them all (prompt discussion about global state, about the down-sides of God objects, ...).
Context is a place to shove global-like data that we want to use a lot of places. But we generally shouldn't.
Introduce With-prefixed functions (and maybe contrast with other persistent data structures / builders / ...)
Talk through WithValue with a user ID as an example
Talk through WithTimeout and Done as just a library written using WithValue.
that is a good thought, IMO.
I am sure we must be using timeout somewhere. we certainly have material on the need for timeouts in the primer, don't we?
i think we could probably weave this into at least one of the exercises. maybe with some explicit demos of client cancellation as well, and a description of why that's useful.
Both of our Cohort 2 trainees have raised existential questions around Context. We may want to find some useful references or write up some material about this.
We may even want to make a "implement
WithTimeout
usingWithValue
" exercise to show that there's no magic here, it's really just a fancy key-value store.(I've also gone on a tangent around persistent data structures when talking through this, unclear whether that's actually useful/worthwhile :))
The text was updated successfully, but these errors were encountered: