Skip to content

Commit f0a1457

Browse files
committed
Revise changelog
1 parent 41b7e0b commit f0a1457

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

doc/changelog/1.7.0.md

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,8 @@ This is a big release with big release notes. Grab a coffee and enjoy!
9090

9191
* **Bugfix**: `setState(newState: S, callback: Callback)` wasn't calling the specified `Callback` (!!!)
9292

93-
* Added async versions of all `{set,mod}State` functions that return `AsyncCallback`s that resume when React has
94-
finished applying the state change.
95-
96-
If you write a callback that must be executed after a state update, you would've learned that `setState(s) >> c`
97-
would be a bug because React applies state changes asynchronously. The correct way of writing it would be
98-
`setState(s, c)`. With this change you could now also write `setStateAsync(s) >> c.toAsyncCallback`.
93+
* Added async versions of all `{set,mod}State` functions.
94+
These return `AsyncCallback`s that resume when React has finished applying the state change.
9995

10096
```scala
10197
.setStateAsync(S) : AsyncCallback[Unit]
@@ -106,11 +102,17 @@ This is a big release with big release notes. Grab a coffee and enjoy!
106102
.modStateOptionAsync((S, P) => Option[S]): AsyncCallback[Unit]
107103
```
108104

105+
If you write a callback that must be executed after a state update, you would've learned that `setState(s) >> c`
106+
would be a bug because React applies state changes asynchronously. The correct way of writing it would be
107+
`setState(s, c)`. With this change you could now also write `setStateAsync(s) >> c.toAsyncCallback`.
108+
109109
* Made `Callback(To)` and `AsyncCallback` stack-safe
110110

111111
* Added to `AsyncCallback[A]`:
112112
* `def sync: CallbackTo[Either[AsyncCallback[A], A]]` to turn a `AsyncCallback` into a synchronous `Callback` when possible
113-
* `def unsafeRunNowSync(): A` for unit testing
113+
* `def unsafeRunNowSync(): A` which is handy in unit tests where you've taken care to ensure that test code provides
114+
`AsyncCallback`s that are actually synchronous under the hood. (eg. instead of a real async AJAX call your test provides
115+
an `AsyncCallback` that returns a test response immediately)
114116
* `def delay[A](a: => A): AsyncCallback[A]` and deprecate `.point`
115117
* versions of existing methods that `AsyncCallback` arguments, to take `CallbackTo` instances instead:
116118
```scala
@@ -140,22 +142,31 @@ This is a big release with big release notes. Grab a coffee and enjoy!
140142

141143
* Added to `StateSnapshot[S]`:
142144
```scala
143-
.narrowOption [T <: S] : Option[StateSnapshot[T]]
144-
.unsafeWiden [T >: S] : StateSnapshot[T]
145-
.zoomStateOption [T](f: S => Option[T])(g: T => S => S) : Option[StateSnapshot[T]]
146-
.withReuse.zoomStateOption[T](optional: Reusable[(S => Option[T], T => S => S)]): Option[StateSnapshot[T]]
145+
/** @return `None` if `value: S` isn't `value: T` as well. */
146+
def narrowOption[T <: S]: Option[StateSnapshot[T]]
147+
148+
/** Unsafe because writes may be dropped.
149+
*
150+
* Eg. if you widen a `StateSnapshot[Banana]` into `StateSnapshot[Food]`,
151+
* calling `setState(banana2)` will work but `setState(pasta)` will be silently ignored.
152+
*/
153+
def unsafeWiden[T >: S]: StateSnapshot[T]
154+
155+
def zoomStateOption[T](f: S => Option[T])(g: T => S => S): Option[StateSnapshot[T]]
156+
157+
def withReuse.zoomStateOption[T](optional: Reusable[(S => Option[T], T => S => S)]): Option[StateSnapshot[T]]
147158

148159
// If using `import MonocleReact._`
149-
.zoomStateO [B](o: monocle.Optional[A, B]) : Option[StateSnapshot[B]]
150-
.withReuse.zoomStateO [B](o: Reusable[monocle.Optional[A, B]]): Option[StateSnapshot[B]]
160+
.zoomStateO [B](o: monocle.Optional[A, B]) : Option[StateSnapshot[B]]
161+
.withReuse.zoomStateO[B](o: Reusable[monocle.Optional[A, B]]): Option[StateSnapshot[B]]
151162
```
152163

153164
* Added to `StateSnapshot`:
154165
* `(value).readOnly` to create a `StateSnapshot` that ignores writes/updates
155166
* `.withReuse(value).readOnly` to create a `StateSnapshot` that ignores writes/updates
156167
* `.withReuse.prepareViaProps[P, I]($: GenericComponent.MountedPure[P, _])(f: P => I)`
157168
* `.withReuse.prepareViaCallback[I](cb: CallbackTo[I])`
158-
* [example of how these can be used -- it's the recommended way to handle state with scalajs-react](https://japgolly.github.io/scalajs-react/#examples/state-snapshot-2)
169+
* [example of how these can be used -- **this is the recommended way to handle state with scalajs-react**](https://japgolly.github.io/scalajs-react/#examples/state-snapshot-2)
159170

160171
* Changes in `object Reusability`:
161172
* update `.caseClassExcept` to accept `String` arguments instead of `scala.Symbol`s,
@@ -197,8 +208,7 @@ This is a big release with big release notes. Grab a coffee and enjoy!
197208
* Testing
198209
* `ReactTestUtils` methods now only warn when failing to unmount a component, rather than throwing an error
199210
* Event simulation in tests now ensures that default properties of events are set.
200-
201-
Example: you don't need to manually specify `defaultPrevented` or `altKey` in a `Simulate.click`, they now default to `false`.
211+
<br>Example: you don't need to manually specify `defaultPrevented` or `altKey` in a `Simulate.click`, they now default to `false`.
202212

203213
* `MonocleReact`
204214
* the `modStateL` and `modStateOptionL` methods now accept all kinds of appropriate optics instead of just lenses

0 commit comments

Comments
 (0)