diff --git a/package.json b/package.json index 3fccc42..8a3b62f 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/Meteor.js b/src/Meteor.js index 98f6fe0..bf69c45 100644 --- a/src/Meteor.js +++ b/src/Meteor.js @@ -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); } }, @@ -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 => {