Skip to content

Commit 161f116

Browse files
committed
Run migration over docs
1 parent 0b4645e commit 161f116

File tree

7 files changed

+101
-101
lines changed

7 files changed

+101
-101
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,4 @@ Rename {Read,Write}{Id,CB} in StateAccessor?
187187

188188
new releases for scalacss & test-state
189189

190+
router's {dyn,}render{,R}

doc/EXTRA.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ These help your components listen and react to external events or data changes.
2626
##### Usage
2727
```scala
2828
// A listening component
29-
val component = ReactComponentB[...]
29+
val component = ScalaComponent.build[...]
3030
...
3131
.backend(_ => new OnUnmount.Backend)
3232
...
33-
.configure(Listenable.install(...))
33+
.configure(Listenable.listen(...))
3434
...
3535

3636
// A simple broadcaster
@@ -71,7 +71,7 @@ This will cause logging to occur at React component lifecycle stages.
7171

7272
##### Usage
7373
```scala
74-
val component = ReactComponentB[...]
74+
val component = ScalaComponent.build[...]
7575
...
7676
.configure(LogLifecycle.short) // Logs the component name and stage
7777
.configure(LogLifecycle.verbose) // Logs component props and state as well
@@ -110,7 +110,7 @@ class MyBackend extends OnUnmount {
110110
onUnmount( Callback.log("Component unmounting...") )
111111
}
112112

113-
val eg = ReactComponentB[Unit]("Example")
113+
val eg = ScalaComponent.build[Unit]("Example")
114114
.stateless
115115
.backend(_ => new MyBackend)
116116
.render(_ => ???)
@@ -130,7 +130,7 @@ import scala.concurrent.duration._
130130

131131
class MyBackend extends TimerSupport
132132

133-
val Timer = ReactComponentB[Unit]("Timer")
133+
val Timer = ScalaComponent.build[Unit]("Timer")
134134
.initialState(0L)
135135
.backend(_ => new MyBackend)
136136
.render_S(s => <.div("Seconds elapsed: ", s))

doc/PERFORMANCE.md

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ libraryDependencies += "com.github.japgolly.scalajs-react" %%% "extra" % "0.11.3
1515

1616
### Contents
1717

18-
- [`React.addons.Perf`](#reactaddonsperf)
18+
- [`ReactAddons.Perf`](#reactaddonsperf)
1919
- [`Reusability`](#reusability)
2020
- [Usage](#usage)
2121
- [Example](#example)
@@ -34,7 +34,7 @@ libraryDependencies += "com.github.japgolly.scalajs-react" %%% "extra" % "0.11.3
3434
- [`Px` doesn't have `Reusability`](#px-doesnt-have-reusability)
3535

3636

37-
`React.addons.Perf`
37+
`ReactAddons.Perf`
3838
===================
3939
React addons come with performance tools. See https://facebook.github.io/react/docs/perf.html.
4040

@@ -70,7 +70,7 @@ and Scalaz classes `\/` and `\&/`. For all other types, you'll need to teach it
7070
* `Reusability.caseClassExcept` for case classes of your own where you want to exclude some fields.
7171
* `Reusability.caseClassExceptDebug` as above, but shows you the code that the macro generates.
7272
* `Reusability.by(A => B)` to use a subset (`B`) of the subject data (`A`).
73-
* `Reusability.fn((A, B) => Boolean)` to hand-write custom logic.
73+
* `Reusability((A, B) => Boolean)` to hand-write custom logic.
7474
* `Reusability.byIterator` uses an `Iterable`'s iterator to check each element in order.
7575
* `Reusability.indexedSeq` uses `.length` and `.apply(index)` to check each element in order.
7676
* `Reusability.{double,float}` exist and require a tolerance to be specified.
@@ -94,7 +94,7 @@ case class Props(name: String, age: Option[Int], pic: Picture)
9494
implicit val picReuse = Reusability.by((_: Picture).id) // ← only check id
9595
implicit val propsReuse = Reusability.caseClass[Props] // ← check all fields
9696

97-
val component = ReactComponentB[Props]("Demo")
97+
val component = ScalaComponent.build[Props]("Demo")
9898
.render_P(p =>
9999
<.div(
100100
<.p("Name: ", p.name),
@@ -157,7 +157,7 @@ type State = Map[PersonId, PersonData]
157157
type PersonId = Long
158158
type PersonData = String
159159

160-
val topComponent = ReactComponentB[State]("Demo")
160+
val topComponent = ScalaComponent.build[State]("Demo")
161161
.initialState_P(identity)
162162
.renderBackend[Backend]
163163
.build
@@ -179,12 +179,11 @@ case class PersonEditorProps(name: String, update: String ~=> Callback) // ←
179179

180180
implicit val propsReuse = Reusability.caseClass[PersonEditorProps]
181181

182-
val personEditor = ReactComponentB[PersonEditorProps]("PersonEditor")
182+
val personEditor = ScalaComponent.build[PersonEditorProps]("PersonEditor")
183183
.render_P(p =>
184-
<.input(
185-
^.`type` := "text",
186-
^.value := p.name,
187-
^.onChange ==> ((e: ReactEventI) => p.update(e.target.value)))) // ← Use as normal
184+
<.input.text(
185+
^.value := p.name, // ← Use as normal
186+
^.onChange ==> ((e: ReactEventFromInput) => p.update(e.target.value))))
188187
.configure(Reusability.shouldComponentUpdate) // ← shouldComponentUpdate like magic
189188
.build
190189
```
@@ -198,7 +197,7 @@ props/state, the function will forever be based on data that can go stale.
198197
Example:
199198
```scala
200199
@Lenses case class Person(name: String, age: Int)
201-
case class Props(person: ReusableVar[Person], other: Other)
200+
case class Props(person: StateSnapshot[Person], other: Other)
202201

203202
// THIS IS BAD!!
204203
ReusableFn($.props.runNow().person setL Props.name)
@@ -233,13 +232,13 @@ For these examples imagine `$` to be your component's scope instance, eg. `Backe
233232
You'll find that if you try `ReusableFn($.method)` Scala will fail to infer the correct types.
234233
Use `ReusableFn($).method` instead to get the types that you expect.
235234

236-
Example: instead of `ReusableFn($.setState)` use `ReusableFn($).setState` and you will correctly get a `S ~=> Callback`.
235+
Example: instead of `ReusableFn($.setState)` use `ReusableFn.state($).set` and you will correctly get a `S ~=> Callback`.
237236

238237
2. `ReusableFn.endo____`.
239238

240239
Anytime the input to your `ReusableFn` is an endofunction (`A => A`), additional methods starting with `endo` become available.
241240

242-
Specifically, `ReusableFn($).modState` returns a `(S => S) ~=> Callback` which you will often want to transform.
241+
Specifically, `ReusableFn.state($).mod` returns a `(S => S) ~=> Callback` which you will often want to transform.
243242
These examples would be available on an `(S => S) ~=> U`:
244243

245244
* `endoCall (S => (A => S)): A ~=> U` - Call a 1-arg function on `S`.
@@ -258,14 +257,14 @@ For these examples imagine `$` to be your component's scope instance, eg. `Backe
258257

259258
// Shorter using helpers described above
260259
val short: Int ~=> (String ~=> Callback) =
261-
ReusableFn($).modState.endoCall2(_.updated)
260+
ReusableFn.state($).mod.endoCall2(_.updated)
262261
```
263262

264-
3. `ReusableFn($ zoomL lens)`
263+
3. `ReusableFn($ zoomStateL lens)`
265264

266265
Lenses provide an abstraction over read-and-write field access.
267266
Using Monocle, you can annotate your case classes with `@Lenses` to gain automatic lenses.
268-
`$ zoomL lens` will then narrow the scope of its state to the field targeted by the given lens.
267+
`$ zoomStateL lens` will then narrow the scope of its state to the field targeted by the given lens.
269268
This can then be used with `ReusableFn` as follows:
270269

271270
```scala
@@ -337,24 +336,24 @@ there is also `ReusableVar`.
337336
```scala
338337
@Lenses case class State(name: String, desc: String)
339338

340-
val topComponent = ReactComponentB[State]("Demo")
339+
val topComponent = ScalaComponent.build[State]("Demo")
341340
.initialState_P(identity)
342341
.renderP { ($, p) =>
343-
val setName = ReusableVar.state($ zoomL State.name)
344-
val setDesc = ReusableVar.state($ zoomL State.desc)
342+
val setName = StateSnapshot.withReuse.zoomL(State.name).of($)
343+
val setDesc = StateSnapshot.withReuse.zoomL(State.desc).of($)
345344

346345
<.div(
347346
stringEditor(setName),
348347
stringEditor(setDesc))
349348
}
350349
.build
351350

352-
lazy val stringEditor = ReactComponentB[ReusableVar[String]]("StringEditor")
351+
lazy val stringEditor = ScalaComponent.build[StateSnapshot[String]]("StringEditor")
353352
.render_P(p =>
354353
<.input(
355354
^.`type` := "text",
356355
^.value := p.value,
357-
^.onChange ==> ((e: ReactEventI) => p.set(e.target.value))))
356+
^.onChange ==> ((e: ReactEventFromInput) => p.set(e.target.value))))
358357
.configure(Reusability.shouldComponentUpdate)
359358
.build
360359
```
@@ -387,7 +386,7 @@ Create a non-derivative `Px` using one of these:
387386
Doesn't change until you explicitly call `set()`.
388387

389388
```scala
390-
val num = Px(123)
389+
val num = Px(123).withReuse.manualUpdate
391390
num.set(666)
392391
```
393392

@@ -399,10 +398,10 @@ Create a non-derivative `Px` using one of these:
399398
case class State(name: String, age: Int)
400399

401400
class ComponentBackend($: BackendScope[User, State]) {
402-
val user = Px.thunkM($.props)
403-
val stateAge = Px.thunkM($.state.age)
401+
val user = Px($.props).withReuse.manualRefresh
402+
val stateAge = Px($.state.age).withReuse.manualRefresh
404403

405-
def render: ReactElement = {
404+
def render: VdomElement = {
406405
// Every render cycle, refresh Pxs. Unnecessary changes will be discarded.
407406
Px.refresh(user, stateAge)
408407

@@ -426,16 +425,16 @@ Create a non-derivative `Px` using one of these:
426425
}
427426

428427
class ComponentBackend($: BackendScope[Props, _]) {
429-
val usersOnline = Px.thunkA(InternalGlobalState.usersOnline)
428+
val usersOnline = Px(InternalGlobalState.usersOnline).withReuse.autoRefresh
430429

431430
// Only updated when the InternalGlobalState changes
432-
val coolGraphOfUsersOnline: Px[ReactElement] =
431+
val coolGraphOfUsersOnline: Px[VdomElement] =
433432
for (u <- usersOnline) yield
434433
<.div(
435434
<.h3("Users online: ", u),
436435
coolgraph(u))
437436

438-
def render: ReactElement =
437+
def render: VdomElement =
439438
<.div(
440439
"Hello ", $.props.username,
441440
coolGraphOfUsersOnline.value())
@@ -466,8 +465,8 @@ Derivative `Px`s are created by:
466465

467466
Example:
468467
```scala
469-
val project : Px[Project] = Px.bs($).propsM
470-
val viewSettings: Px[ViewSettings] = Px.bs($).stateM(_.viewSettings)
468+
val project : Px[Project] = Px.props($).withReuse.manualRefresh
469+
val viewSettings: Px[ViewSettings] = Px.state($).map(_.viewSettings).withReuse.manualRefresh
471470

472471
// Using .map
473472
val columns : Px[Columns] = viewSettings.map(_.columns)
@@ -507,15 +506,15 @@ In short, do not use `Px` in a component's props or state. Instead of `Px[A]`, j
507506
case class Component2Props(count: Px[Int])
508507
class Component1Backend {
509508
val px: Px[Int] = ...
510-
def render: ReactElement =
509+
def render: VdomElement =
511510
Component2(Component2Props(px))
512511
}
513512

514513
// Good
515514
case class Component2Props(count: Int)
516515
class Component1Backend {
517516
val px: Px[Int] = ...
518-
def render: ReactElement =
517+
def render: VdomElement =
519518
Component2(Component2Props(px.value()))
520519
}
521520
```
@@ -529,7 +528,7 @@ import Px.AutoValue._
529528
case class Component2Props(count: Int)
530529
class Component1Backend {
531530
val px: Px[Int] = ...
532-
def render: ReactElement =
531+
def render: VdomElement =
533532
Component2(Component2Props(px)) // .value() called implicitly
534533
}
535534
```

doc/ROUTER.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ Each route can be associated with an action. The following actions are available
123123

124124
| DSL | Args | Description |
125125
|-----|------|-------------|
126-
| `render` | `ReactElement` | Render something. |
127-
| `renderR` | `RouterCtl => ReactElement` | Render something using a [`RouterCtl`](#routerctl). |
128-
| `dynRender` | `Page => ReactElement` | Render something using the current page.<br>* *Dynamic routes only.* |
129-
| `dynRenderR` | `(Page, RouterCtl) => ReactElement` | Render something using the current page, and a [`RouterCtl`](#routerctl).<br>* *Dynamic routes only.* |
126+
| `render` | `VdomElement` | Render something. |
127+
| `renderR` | `RouterCtl => VdomElement` | Render something using a [`RouterCtl`](#routerctl). |
128+
| `dynRender` | `Page => VdomElement` | Render something using the current page.<br>* *Dynamic routes only.* |
129+
| `dynRenderR` | `(Page, RouterCtl) => VdomElement` | Render something using the current page, and a [`RouterCtl`](#routerctl).<br>* *Dynamic routes only.* |
130130
| `redirectToPage` | `(Page)`<br>`(implicit Redirect.Method)` | Redirect to a page. |
131131
| `redirectToPath` | `(Path | String)`<br>`(implicit Redirect.Method)` | Redirect to a path (a URL suffix proceding the `BaseUrl`). |
132132

@@ -256,7 +256,7 @@ Example: This creates a route in the format of `item/<id>`.
256256
```scala
257257
case class ItemPage(id: Int) extends MyPage
258258

259-
val itemPage = ReactComponentB[ItemPage]("Item page")
259+
val itemPage = ScalaComponent.build[ItemPage]("Item page")
260260
.render(p => <.div(s"Info for item #${p.id}"))
261261
.build
262262

@@ -357,7 +357,7 @@ A conversion to the former is just a `.contramap` or `.narrow` call away for the
357357

358358
Here a subset of useful methods. Use IDE auto-complete or check the source for the full list.
359359

360-
* `link(Page): ReactTag` - Create a link to a page.
360+
* `link(Page): VdomTag` - Create a link to a page.
361361

362362
```scala
363363
ctl.link(Specials)("Today's Specials", ^.color := "red")
@@ -517,7 +517,7 @@ val privatePages = (emptyRule
517517

518518
### Rendering with a layout
519519

520-
Once you have a `RouterConfig`, you can call `.renderWith` on it to supply your own render function that will be invoked each time a route is rendered. It takes a function in the shape: `(RouterCtl[Page], Resolution[Page]) => ReactElement` where a `Resolution` is:
520+
Once you have a `RouterConfig`, you can call `.renderWith` on it to supply your own render function that will be invoked each time a route is rendered. It takes a function in the shape: `(RouterCtl[Page], Resolution[Page]) => VdomElement` where a `Resolution` is:
521521

522522
```scala
523523
/**
@@ -526,7 +526,7 @@ Once you have a `RouterConfig`, you can call `.renderWith` on it to supply your
526526
* @param page Data representation (or command) of what will be drawn.
527527
* @param render The render function provided by the rules and logic in [[RouterConfig]].
528528
*/
529-
final case class Resolution[P](page: P, render: () => ReactElement)
529+
final case class Resolution[P](page: P, render: () => VdomElement)
530530
```
531531

532532
Thus using the given `RouterCtl` and `Resolution` you can wrap the page in a layout, link to other pages, highlight the current page, etc.

0 commit comments

Comments
 (0)