New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-meteor

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-meteor

DDP React-native Client

  • 1.0.0-beta12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

GitHub version npm version Dependency Status devDependency Status MIT bitHound Score

react-native-meteor

Meteor-like methods for React Native. Currently in v1.0.0-beta12 ! 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@latest

!! See detailed installation guide

Example usage


import { View, Text, Component } from 'react-native';
import Meteor, { connectMeteor, MeteorListView } from 'react-native-meteor';

/*
* Uses decorators (see detailed installation to activate it)
* Or use :

  class Todos extends Component {
    ...
  }
  connectMeteor(Todos);
  export default Todos;

*/

@connectMeteor
export default class App extends Component {
  componentWillMount() {
    const url = 'http://192.168.X.X:3000/websocket';
    Meteor.connect(url);
  }
  startMeteorSubscriptions() {
    Meteor.subscribe('todos');
    Meteor.subscribe('settings');
  }
  getMeteorData() {
    return {
      settings: Meteor.collection('settings').findOne()
    };
  }
  renderRow(todo) {
    return (
      <Text>{todo.title}</Text>
    );
  }
  render() {
    const { settings } = this.data;

    <View>
      <Text>{settings.title}</Text>
        <MeteorListView
          collection="todos"
          selector={{done: true}}
          options={{sort: {createdAt: -1}}}
          renderRow={this.renderRow}
        />
    </View>

  }
}

connectMeteor

startMeteorSubscriptions

Inside this method, you can create subscriptions (see below) when component is mounted. It will automatically unsubscribe if the component is unmounted.

Meteor.subscribe
Example usage

your server side:

Meteor.publish('todos', function(done, options){
    return Todos.find({ done: done }, options);
});

your react-native client code:

//Meteor subscribe can be used like on meteor official site
Meteor.subscribe('todos', true, {limit: 10, sort: {createdAt: -1}});

getMeteorData

Inside getMeteorData, you can access any Meteor reactive data source, which means :

Additionals collection methods

MeteorListView Component

Same as ListView Component but does not need dataSource and accepts three arguments :

  • collection string required
  • selector [string / object]
  • url object

Example usage

<MeteorListView
  collection="todos"
  selector={{done: true}}
  options={{sort: {createdAt: -1}}}
  renderItem={this.renderItem}
/>

API

Meteor.connect(endpoint, options)

Connect to a DDP server. You only have to do this once in your app.

Arguments
  • url string required
  • options object Available options are :
    • autoConnect boolean [true] whether to establish the connection to the server upon instantiation. When false, one can manually establish the connection with the Meteor.ddp.connect method.
    • autoReconnect boolean [true] whether to try to reconnect to the server when the socket connection closes, unless the closing was initiated by a call to the disconnect method.
    • reconnectInterval number [10000] the interval in ms between reconnection attempts.

Meteor.disconnect()

Disconnect from the DDP server.

Meteor methods

Meteor.ddp

Once connected to the ddp server, you can access every method available in ddp.js.

  • Meteor.ddp.on('connected')
  • Meteor.ddp.on('added')
  • Meteor.ddp.on('changed')
  • ...

TODO

Pull Requests are welcome ! :)

Keywords

FAQs

Package last updated on 15 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc