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