Skip to content

Commit

Permalink
Fix issue 41
Browse files Browse the repository at this point in the history
  • Loading branch information
Théo mathieu committed Mar 25, 2016
1 parent 51a9970 commit 1b5d839
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/components/ComplexListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ export default class MeteorListView extends Component {
})
};
}
componentWillReceiveProps(props) {
const { elements } = props;

const elems = elements();
this.setState({
ds: this.state.ds.cloneWithRows(elems)
});

}
componentWillMount() {

const { elements } = this.props;
Expand Down
19 changes: 14 additions & 5 deletions src/components/ListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,22 @@ export default class MeteorListView extends Component {
})
};
}
componentWillReceiveProps(props) {
const { collection, selector, options } = props;

this.update(Data.db[collection].find(selector, options));
}
componentWillMount() {
const { collection, selector, options } = this.props;


this.update = results=>{
this.setState({
ds: this.state.ds.cloneWithRows(results)
});
};


if(!Data.db[collection]) {
Data.db.addCollection(collection)
}
Expand All @@ -40,11 +53,7 @@ export default class MeteorListView extends Component {
return Data.db[collection].find(selector, options);
});

this.items.subscribe(results=>{
this.setState({
ds: this.state.ds.cloneWithRows(results)
});
});
this.items.subscribe(this.update);
}
componentWillUnmount() {
this.items.dispose();
Expand Down

0 comments on commit 1b5d839

Please sign in to comment.