Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mqtt-react",
"version": "0.0.2",
"version": "0.0.3",
"description": "Connecting MQQT to React Components",
"main": "./lib/index.js",
"scripts": {
Expand Down Expand Up @@ -33,12 +33,13 @@
"babel": "inherit"
},
"dependencies": {
"mqtt": "^2.7.0"
"mqtt": "^3.0.0",
"object.omit": "^3.0.0"
},
"peerDependencies": {
"prop-types": "^15.5.8",
"react": "^15.5.0",
"react-dom": "^15.5.0",
"prop-types": "^15.5.8"
"react-dom": "^15.5.0"
},
"devDependencies": {
"ava": "^0.19.1",
Expand All @@ -51,9 +52,9 @@
"babel-preset-stage-0": "^6.24.1",
"cross-env": "^4.0.0",
"enzyme": "^2.8.2",
"prop-types": "^15.5.8",
"react": "^15.5.0",
"react-dom": "^15.5.0",
"prop-types": "^15.5.8",
"react-test-renderer": "^15.5.4",
"sinon": "^2.2.0",
"webpack": "^2.4.1"
Expand Down
4 changes: 0 additions & 4 deletions src/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ export default class Connector extends Component {
this.mqtt.on('close', this._makeStatusHandler('closed'));
this.mqtt.on('offline', this._makeStatusHandler('offline'));
this.mqtt.on('error', console.error);


}

componentWillUnmount(){
Expand All @@ -59,6 +57,4 @@ export default class Connector extends Component {
renderConnected() {
return Children.only(this.props.children);
}


}
3 changes: 0 additions & 3 deletions src/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {Component, createElement} from "react";
import PropTypes from "prop-types";
import omit from "object.omit";


function parse(message) {
try {
const item = JSON.parse(message);
Expand All @@ -22,7 +21,6 @@ function defaultDispatch(topic, message, packet) {
this.setState({ data: newData });
};


export default function subscribe(opts = { dispatch: defaultDispatch }) {
const { topic } = opts;
const dispatch = (opts.dispatch) ? opts.dispatch : defaultDispatch;
Expand All @@ -48,7 +46,6 @@ export default function subscribe(opts = { dispatch: defaultDispatch }) {
this.client.on('message', this.handler);
}


componentWillMount() {
this.subscribe();
}
Expand Down
4 changes: 1 addition & 3 deletions test/connector.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {shallow} from "enzyme";
import {EventEmitter} from "events";
import Connector from "../src/connector";


describe('Connector', (test) => {
const DIV_ID = 'content';
test('should render children', (t) => {
Expand All @@ -16,5 +15,4 @@ describe('Connector', (test) => {
)
t.true(mounted.find(`div#${DIV_ID}`).length === 1);
})

});
});
5 changes: 1 addition & 4 deletions test/subscribe.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Sinon from 'sinon';
import subscribe from '../src/subscribe';
import {EventEmitter} from 'events';


class mockClient extends EventEmitter {
subscribe = Sinon.spy();
publish = Sinon.spy((topic, message) => {
Expand Down Expand Up @@ -61,6 +60,4 @@ describe('Subscribe', (test) => {
t.truthy(data[0]);
t.true(data[0].value === demoMessage.value);
})


});
});
Loading