Skip to content

Commit 83bdb49

Browse files
committed
Remove non-reusable methods from StateSnapshot.withReuse
1 parent 616356d commit 83bdb49

File tree

2 files changed

+0
-24
lines changed

2 files changed

+0
-24
lines changed

extra/src/main/scala/japgolly/scalajs/react/extra/StateSnapshot.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ object StateSnapshot {
4646
def apply[S](value: S): FromValue[S] =
4747
new FromValue(value)
4848

49-
def of[I, S](i: I)(implicit t: StateAccessor.ReadImpureWritePure[I, S], r: Reusability[S]): StateSnapshot[S] =
50-
apply(t.state(i)).setStateVia(i)(t, r)
51-
5249
/** This is meant to be called once and reused so that the setState callback stays the same. */
5350
def prepare[S](f: S => Callback): FromSetStateFn[S] =
5451
new FromSetStateFn(Reusable.fn(f))
@@ -80,9 +77,6 @@ object StateSnapshot {
8077
final class FromValue[S](private val value: S) extends AnyVal {
8178
def apply(set: S ~=> Callback)(implicit r: Reusability[S]): StateSnapshot[S] =
8279
new StateSnapshot(value, set, r)
83-
84-
def setStateVia[I](i: I)(implicit t: StateAccessor.WritePure[I, S], r: Reusability[S]): StateSnapshot[S] =
85-
apply(Reusable.fn(t setState i))(r)
8680
}
8781

8882
final class FromSetStateFn[S](private val set: S ~=> Callback) extends AnyVal {

test/src/test/scala/japgolly/scalajs/react/extra/StateSnapshotTest.scala

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,7 @@ object StateSnapshotTest extends TestSuite {
5959
import japgolly.scalajs.react.test.InferenceUtil._
6060
def SS = StateSnapshot.withReuse
6161
implicit def rs: Reusability[S] = ???
62-
'of {
63-
test[Render ](SS.of(_)).expect[StateSnapshot[S]]
64-
compileError(""" test[StateAccessP ](SS.of(_)) """) // lack safe read
65-
compileError(""" test[Backend ](SS.of(_)) """) // lack safe read
66-
compileError(""" test[ScalaMountedCB](SS.of(_)) """) // lack safe read
67-
compileError(""" test[JsMounted ](SS.of(_)) """) // use (x.state).setStateVia(x.pure)
68-
compileError(""" test[ScalaMountedId](SS.of(_)) """) // use (x.state).setStateVia(x.pure)
69-
compileError(""" test[StateAccessI ](SS.of(_)) """) // use (x.state).setStateVia(x.pure)
70-
}
7162
'apply_apply - test[S ~=> Callback](SS(S)(_)).expect[StateSnapshot[S]]
72-
'apply_setStateVia {
73-
test[Render ](SS(S).setStateVia(_)).expect[StateSnapshot[S]]
74-
test[Backend ](SS(S).setStateVia(_)).expect[StateSnapshot[S]]
75-
test[ScalaMountedCB](SS(S).setStateVia(_)).expect[StateSnapshot[S]]
76-
test[StateAccessP ](SS(S).setStateVia(_)).expect[StateSnapshot[S]]
77-
compileError(""" test[JsMounted ](SS(S).setStateVia(_)) """) // use setStateVia(x.pure)
78-
compileError(""" test[ScalaMountedId](SS(S).setStateVia(_)) """) // use setStateVia(x.pure)
79-
compileError(""" test[StateAccessI ](SS(S).setStateVia(_)) """) // use setStateVia(x.pure)
80-
}
8163
'zoom {
8264
def rs = ??? // shadow
8365
implicit def rt: Reusability[T] = ???

0 commit comments

Comments
 (0)