Skip to content

Commit

Permalink
Fix #32
Browse files Browse the repository at this point in the history
  • Loading branch information
Théo mathieu committed Mar 20, 2016
1 parent 6c77fdd commit cd5aba2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# react-native-meteor

Meteor-like methods for React Native. **Currently in v1.0.0-beta17** ! For old docs, see [v0.6.2 documentation](https://github.com/inProgress-team/react-native-meteor/tree/0.6.2) (classic ddp interface).
Meteor-like methods for React Native. **Currently in v1.0.0-beta18** ! For old docs, see [v0.6.2 documentation](https://github.com/inProgress-team/react-native-meteor/tree/0.6.2) (classic ddp interface).

## What is it for ?

Expand Down
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-beta17",
"version": "1.0.0-beta18",
"description": "DDP React-native Client",
"main": "src/Meteor.js",
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions src/Data.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ export default {
return this._endpoint.substring(0, this._endpoint.indexOf('/websocket'));
},

waitDdpReady(cb) {
if(this.ddp) {
cb();
} else {
setTimeout(()=>{
this.waitDdpReady(cb);
}, 10);
}
},

_cbs: [],
onChange(cb) {
this.db.on('change', cb);
Expand Down
23 changes: 13 additions & 10 deletions src/components/Mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ import Data from '../Data';
export default {
componentWillMount() {

if(this.getMeteorData) {
this.data = {};
this._meteorDataManager = new MeteorDataManager(this);
const newData = this._meteorDataManager.calculateData();
this._meteorDataManager.updateData(newData);
}
Data.waitDdpReady(()=>{
if(this.getMeteorData) {
this.data = {};
this._meteorDataManager = new MeteorDataManager(this);
const newData = this._meteorDataManager.calculateData();
this._meteorDataManager.updateData(newData);
}

if(this.startMeteorSubscriptions) {
this._meteorSubscriptionsManager = new MeteorSubscriptionsManager(this);
this._meteorSubscriptionsManager.getMeteorSubscriptions();
}
});

if(this.startMeteorSubscriptions) {
this._meteorSubscriptionsManager = new MeteorSubscriptionsManager(this);
this._meteorSubscriptionsManager.getMeteorSubscriptions();
}

},
componentWillUpdate(nextProps, nextState) {
Expand Down

0 comments on commit cd5aba2

Please sign in to comment.