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

  • 0.5.0
  • 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 react-native MIT bitHound Score

react-native-meteor

React-native meteor ddp adapter

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

Install

npm i --save react-native-meteor

Example usage

var Example = React.createClass({
  getInitialState: function() {
    return {
      dataSource: new ListView.DataSource({
        rowHasChanged: (row1, row2) => row1!==row2,
      }),
      loaded: false,
    };
  },
  componentDidMount: function() {
    var self = this;

    meteor.connect('http://YOURIP:3000/websocket');

    meteor.on('connected', function () {
      console.log('connected');
    });

    this.tasksSub = meteor.subscribe('tasks', function (tasks) {
      self.setState({
        dataSource: self.state.dataSource.cloneWithRows(tasks),
        loaded: true
      });
    });
 },
 componentWillUnmount: function () {
   meteor.unsubscribe(this.tasksSub);
 }
});

Public API

connect(url)

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

Arguments
  • url string required

disconnect()

Disconnect from the ddp server.

subscribe(name, collectionName, params, callback)

Subscribes to a server publication.

Arguments
  • name string required : name of the server subscription

  • collectionName string optional : name of the collection you subscribe (in case the subscription name is different than collection name)

  • params array optional : parameters to pass to the server publish function.

  • callback function required : callback called when there is a change in the publication. Returns all elements.

unsubscribe(id)

Unsubscribes to a server publication.

Arguments
  • id string required : id of the server publication

itemSubscribe(name, collectionName, id, callback)

Subscribes to an item in a collection (the collection need to be subscribed with same name and collection name parameter). Returns the subscriptionId.

Arguments
  • name string required : name of the server subscription

  • collectionName string optional : name of the collection you subscribe (in case the subscription name is different than collection name)

  • id array required : id of the item to subscribe to

  • callback function required : callback called when there is a change to the item. Returns the element.

itemUnsubscribe(name, collectionName, subId)

Unsubscribes to a item subscription.

Arguments
  • name string required : name of the server subscription

  • collectionName string optional : name of the collection you subscribe (in case the subscription name is different than collection name)

  • subId string required : id of the subscription

on(eventName, callback)

Callback when an event is triggered

Arguments
  • eventName string required : 'connected' and 'disconnected' only for the moment

  • callback function required

method(name, [args], callback)

Call a method on the server

Arguments
  • name string required
  • args array required
  • callback method

loginWithEmail(email, password, callback)

Login to meteor server

Arguments
  • email string required
  • password string required
  • callback(err, result) method

loginWithUsername(username, password, callback)

Login to meteor server

Arguments
  • username string required
  • password string required
  • callback(err, result) method

loginWithToken(token, callback)

Login to meteor server via a token

Arguments
  • token string required
  • callback(err, result) method

logout(callback)

Logout from meteor server

Warning

You can only do one subscription on a same collection at one time

Keywords

FAQs

Package last updated on 18 Feb 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