Skip to content

Instantly share code, notes, and snippets.

@melbourne2991
Created May 13, 2020 22:45
Show Gist options
  • Save melbourne2991/b3093187505f2ee9e517bbcaa6d52580 to your computer and use it in GitHub Desktop.
Save melbourne2991/b3093187505f2ee9e517bbcaa6d52580 to your computer and use it in GitHub Desktop.
React-redux reasonml bindings
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