Go to file
Jeronimo Vallelunga 56a60ec5aa Fix: examples build 2017-07-26 20:58:57 -03:00
dist Fix: examples build 2017-07-26 20:58:57 -03:00
docs README: name 2017-07-26 00:39:01 -03:00
example [ISSUE-6] Remove redux-thunk dependency 2017-07-24 23:18:12 -03:00
src Unit Test: fixed 2017-07-25 00:42:00 -03:00
.eslintrc.json Eslint: airbnb configuration 2017-07-11 00:14:52 -03:00
.gitignore Fix: examples build 2017-07-26 20:58:57 -03:00
.jest.json [ISSUE-9] Reafactor Peripheral 2017-07-15 12:58:18 -03:00
.npmignore .npmignore 2017-07-15 01:16:38 -03:00
.nvmrc Travis: .nvmrc 6 2017-07-12 22:50:23 -03:00
.travis.yml #7 & #5: Build and Bundlesize 2017-07-26 20:25:02 -03:00
README.md Removed Yarn 2017-07-26 20:43:43 -03:00
package.json Fix: examples build 2017-07-26 20:58:57 -03:00
webpack.config.js #7 & #5: Build and Bundlesize 2017-07-26 20:25:02 -03:00

README.md

React Bluetooth - Logo
React Bluetooth - Name

Redux middleware to dispatch actions via bluetooth to a peripheral store

Build Status codecov

Redux Bluetooth is a project which consists in two components: webapp middleware, is a redux middleware to dispatch actions via web bluetooth. peripheral store, is a redux store which process actions received over bluetooth and notify changes on every store change.

Install

$ npm install redux-bluetooth

Usage

Webapp

import { createSyncStore } from 'redux-bluetooth/build/webapp';

// ACTIONS, list of actions types to dispatch over bluetooth
const store = createSyncStore(ACTIONS);
import { connect } from 'react-redux';
import { actions } from 'redux-bluetooth/build/webapp';

import Component from './component';

const mapState = state => state;

const mapAction = {
  onConnect: actions.connectStore,
};

export { Component };
export default connect(mapState, mapAction)(Component);

Warning: actions.connectStore must be trigger by an user action. more info

Peripheral

import { connectSyncStore } from 'redux-bluetooth/build/peripheral';

// NAME, name of the peripehral
// STORE, redux store
connectSyncStore(NAME, STORE);

Example

Set up

First, clone this repo and install example dependencies

$ git clone git@github.com:jvallelunga/redux-bluetooth.git
$ cd redux-bluetooth
$ npm run example:install

Start Peripheral

Make sure you have your bluetooth enabled

$ npm run example:start

Open Webapp

Before starting the webapp, go to chrome://flags/#enable-experimental-web-platform-features, enable the highlighted flag, and restart Chrome on your mobile.

Then, Make sure you have your bluetooth enabled.

Finally, open this url https://jvallelunga.github.io/redux-bluetooth/ on your mobile.