Skip to content

Commit

Permalink
Small improvements + fix infinite loop disconnect/reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
Théo mathieu committed Apr 28, 2016
1 parent 383d4ec commit 55d671a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-meteor",
"version": "1.0.0-beta31",
"version": "1.0.0-beta32",
"description": "Full Meteor Client for React Native",
"main": "src/Meteor.js",
"scripts": {
Expand Down
11 changes: 9 additions & 2 deletions src/Meteor.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = {
} else if(Data.ddp) {
Data.ddp.once('connected', cb);
} else {
setTimeout(()=>{ this.waitDdpConnected(cb) }, 500);
setTimeout(()=>{ this.waitDdpConnected(cb) }, 10);
}

},
Expand Down Expand Up @@ -106,9 +106,16 @@ module.exports = {
}
});

let lastDisconnect = null;
Data.ddp.on("disconnected", ()=>{
console.info("Disconnected from DDP server.");
Data.ddp.connect();

if(!lastDisconnect || new Date() - lastDisconnect > 3000) {
Data.ddp.connect();
}

lastDisconnect = new Date();

});

Data.ddp.on("added", message => {
Expand Down

0 comments on commit 55d671a

Please sign in to comment.