This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WrapBackendScope[P, S](b: BackendScope[P, S]){ | |
def props = CallbackTo[P](b.props) | |
def state = CallbackTo[S](b.state) | |
def both = CallbackTo[(P, S)]((b.props, b.state)) | |
def modState(f: S => S, cb: Callback = Callback.empty): Callback = | |
state >>= (s => b.setState(f(s), cb)) | |
def modStateCB(f: S => CallbackTo[S], cb: Callback = Callback.empty): Callback = | |
state >>= (s => b.setStateCB(f(s), cb)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import japgolly.scalajs.react.BackendScope | |
import japgolly.scalajs.react.extra._ | |
import scalaz.syntax.id._ | |
final case class CachingBackendScope[P: Reusability, S: Reusability] | |
(b: BackendScope[P, S]){ outer ⇒ | |
type PropVal[O] = ReactVal[P, O] | |
type StateVal[O] = ReactVal[(P, S), O] |
NewerOlder