Go to file
Jeronimo Vallelunga ba90434a9b Jest verbose true 2019-03-31 09:22:23 -03:00
docs Example 2017-08-12 11:55:46 -03:00
example Fix Example. Change example references, from build to source code. 2019-03-24 11:50:37 -03:00
src Fix Example. Change example references, from build to source code. 2019-03-24 11:50:37 -03:00
.eslintrc.json Eslint: airbnb configuration 2017-07-11 00:14:52 -03:00
.gitignore [ISSUE-14] Multiple clients write support (#16) 2017-11-01 23:58:12 +02:00
.jest.json Jest verbose true 2019-03-31 09:22:23 -03:00
.npmignore [ISSUE-14] Multiple clients write support (#16) 2017-11-01 23:58:12 +02:00
.nvmrc Fix Example. Change example references, from build to source code. 2019-03-24 11:50:37 -03:00
.travis.yml Change Codecov Coverage 2019-03-31 09:10:53 -03:00
README.md Fix Test Configuration 2019-03-31 08:49:38 -03:00
package-lock.json Fix Test Configuration 2019-03-31 08:49:38 -03:00
package.json Change Codecov Coverage 2019-03-31 09:10:53 -03:00

README.md

React Bluetooth - Logo
React Bluetooth - Name

Redux middleware to dispatch actions via bluetooth to a peripheral store

Build Status codecov gzip size

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.

React Bluetooth - Example

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:peripheral:start

Start Webapp Server

In a different terminal window

$ npm run example:webapp:start

Open Webapp

After starting the server you will see something similar to this.

Compiled successfully!

You can now view webapp in the browser.

  Local:            https://localhost:3000/
  On Your Network:  https://192.168.0.105:3000/ 

Before opening 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, use the url On Your Netrowk to access the web app from your mobile.