Skip to content

Commit

Permalink
Rename ref to local
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed Mar 5, 2024
1 parent cc864ad commit 1ad44f2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions mdoc/flavors-of-shared-state.md
Expand Up @@ -253,10 +253,10 @@ Cats Effect provides an `IOLocal`. It does exactly what we want! Let's implement
```scala mdoc:silent
import cats.effect.IOLocal

val localCounter: IO[Counter] = IOLocal(0).map { ref =>
val localCounter: IO[Counter] = IOLocal(0).map { local =>
makeCounter(
ref.update(_ + 1),
ref.get
local.update(_ + 1),
local.get
)
}
```
Expand All @@ -272,13 +272,13 @@ import cats.effect.Resource

case class CounterWithReset(c: Counter, withFreshCounter: IO ~> IO)

val localCounterR: IO[CounterWithReset] = IOLocal(0).map { ref =>
val localCounterR: IO[CounterWithReset] = IOLocal(0).map { local =>
val c = makeCounter(
ref.update(_ + 1),
ref.get
local.update(_ + 1),
local.get
)

CounterWithReset(c, Resource.make(IO.unit)(_ => ref.reset).surroundK)
CounterWithReset(c, Resource.make(IO.unit)(_ => local.reset).surroundK)
}
```

Expand Down

0 comments on commit 1ad44f2

Please sign in to comment.