Created
May 13, 2020 22:45
-
-
Save melbourne2991/b3093187505f2ee9e517bbcaa6d52580 to your computer and use it in GitHub Desktop.
React-redux reasonml bindings
This file contains 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
module type ReduxParams = { | |
type state; | |
type action; | |
}; | |
module Make = (Params: ReduxParams) => { | |
type state = Params.state; | |
type action = Params.action; | |
type reducer = (state, action) => state; | |
type store('r); | |
[@bs.module "redux"] | |
external createStore: (reducer, state) => store(reducer) = "createStore"; | |
module Provider = { | |
[@bs.module "react-redux"] [@react.component] | |
external make: | |
(~store: store(reducer), ~children: React.element, unit) => | |
React.element = | |
"Provider"; | |
}; | |
type selector('p) = state => 'p; | |
type dispatch = action => unit; | |
[@bs.module "react-redux"] | |
external useSelector: selector('p) => 'p = "useSelector"; | |
[@bs.module "react-redux"] | |
external useDispatch: unit => dispatch = "useDispatch"; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment