
react-native-meteor
Meteor-like methods for React Native. Currently in v1.0.0-beta1 ! For old docs, see v0.6.2 documentation (classic ddp interface).
What is it for ?
The purpose of this library is :
- to set up and maintain a ddp connection with a ddp server, freeing the developer from having to do it on their own.
- be fully compatible with react-native and help react-native developers.
- to match with Meteor documentation used with React.
Install
npm i --save react-native-meteor
!! See detailed installation guide
Example usage
import { View, Text, Component } from 'react-native';
import Meteor, { connectMeteor } from 'react-native-meteor';
@connectMeteor
export default class App extends Component {
componentWillMount() {
const url = 'http://192.168.X.X:3000/websocket';
Meteor.connect(url);
}
startMeteorSubscriptions() {
Meteor.subscribe('todos');
}
getMeteorData() {
return {
todos: Meteor.collection('todos').find()
};
}
render() {
const { todos } = this.data;
{todos.map(todo=>{
return (
<View key={todo._id}>
<Text>{todo.title}</Text>
</View>
)
})}
}
}
MeteorMixin
startMeteorSubscriptions
Inside this method, you can create subscriptions (see below) when component is mounted. It will automatically unsubscribe if the component is unmounted.
getMeteorData
Inside getMeteorData, you can access any Meteor reactive data source, which means :
API
Meteor.connect(endpoint)
Connect to a DDP server. You only have to do this once in your app.
Arguments
Meteor methods