bs-react-native-websocket
react-native-websocket component.
This package provide Reasonml bindings forInstallation
$ yarn add bs-react-native-websocket react-native-websocket
Then update your bsconfig.json
, add bs-react-native-websocket
to bs-dependencies.
"bs-dependencies":
Usage
Usage is very similliar to react-native-websocket.
Example:
type state = socketRef: ; let statesocketRef := JsNullable; let component = ReasonReact; let make = _children ...component {socketRef: } <View> <ReactNativeWebsocket url="ws://localhost:5000" onOpen= Js onMessage= Js // event is a Js.dict object onError= Js onClose= Js ref=self reconnect=true /> </View>;
Example of sending data:
// socket is ref to ReactNativeWebsocket component// data is a stringifiedData that you want to sendReactNativeWebsocket;
License
MIT
Contributing
PR's are welcome!