Skip to content

Instantly share code, notes, and snippets.

@oyvindberg
Created August 24, 2015 02:18
Show Gist options
  • Save oyvindberg/0e6e4cce8132f6b8a315 to your computer and use it in GitHub Desktop.
Save oyvindberg/0e6e4cce8132f6b8a315 to your computer and use it in GitHub Desktop.
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))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment