All Projects → ZevenFang → react-meteor

ZevenFang / react-meteor

Licence: Apache-2.0 license
Meteor Reactivity for your React application, inspired by react-native-meteor.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-meteor

meteorpp
Meteor DDP & Minimongo implementation in C++.
Stars: ✭ 22 (+37.5%)
Mutual labels:  meteor, ddp
meteorman
A DDP client with GUI (The Postman for Meteor)
Stars: ✭ 51 (+218.75%)
Mutual labels:  meteor, ddp
hypersubs
an upgraded version of Meteor subscribe, which helps optimize data and performance!
Stars: ✭ 13 (-18.75%)
Mutual labels:  meteor, ddp
meteor-subscription-scope
Scope queries on collections to subscriptions
Stars: ✭ 20 (+25%)
Mutual labels:  meteor, ddp
unity3d-ddp-client
Lightweight DDP client for Unity3D
Stars: ✭ 18 (+12.5%)
Mutual labels:  meteor, ddp
meteor-devtools-evolved
The Meteor framework development tool belt, evolved.
Stars: ✭ 146 (+812.5%)
Mutual labels:  meteor, ddp
meteor-control-mergebox
Control mergebox of publish endpoints
Stars: ✭ 28 (+75%)
Mutual labels:  meteor, ddp
React Landing Page Template
A simple react one page landing page templates for startups/companies
Stars: ✭ 224 (+1300%)
Mutual labels:  meteor
meteor-computed-field
Reactively computed field for Meteor
Stars: ✭ 18 (+12.5%)
Mutual labels:  meteor
Angular Meteor
Angular and Meteor - The perfect stack
Stars: ✭ 2,385 (+14806.25%)
Mutual labels:  meteor
Meteor Google Maps
🗺 Meteor package for the Google Maps Javascript API v3
Stars: ✭ 198 (+1137.5%)
Mutual labels:  meteor
Ews Javascript Api
EWS API for TypeScript/JavaScript - ported from OfficeDev/ews-managed-api - node, cordova, meteor, Ionic, Electron, Outlook Add-Ins
Stars: ✭ 241 (+1406.25%)
Mutual labels:  meteor
meteor-reactive-aggregate
Reactively publish aggregations with Meteor.
Stars: ✭ 100 (+525%)
Mutual labels:  meteor
Simple React Form
The simplest way to handle forms in React
Stars: ✭ 224 (+1300%)
Mutual labels:  meteor
meteoro
Pomodoro App on Meteor
Stars: ✭ 31 (+93.75%)
Mutual labels:  meteor
Analytics
UNMAINTAINED! - Complete Google Analytics, Mixpanel, KISSmetrics (and more) integration for Meteor
Stars: ✭ 211 (+1218.75%)
Mutual labels:  meteor
meteor-autoform-bs-datepicker
Custom "bootstrap-datepicker" input type for AutoForm
Stars: ✭ 25 (+56.25%)
Mutual labels:  meteor
setup-meteor
Set up your GitHub Actions workflow with a specific version of Meteor.js
Stars: ✭ 17 (+6.25%)
Mutual labels:  meteor
qlicker
Open Source Clicker
Stars: ✭ 23 (+43.75%)
Mutual labels:  meteor
awesome-reactioncommerce
⚡️ A collection of awesome things regarding Reaction Commerce. Feel free to contribute!
Stars: ✭ 18 (+12.5%)
Mutual labels:  meteor

react-meteor

build

Meteor Reactivity for your React application :)

Looking for a demo? Try to check out react-meteor-todomvc.

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 and help react developers.
  • to match with Meteor documentation used with React.

Install

npm i --save react-web-meteor

Example usage

import React, { Component } from 'react';
import Meteor, { createContainer } from 'react-web-meteor';

Meteor.connect('ws://192.168.X.X:3000/websocket');//do this only once

class Todo extends Component {
  renderRow(todo) {
    return (
      <span>{todo.title}</span>
    );
  }
  render() {
    const { settings, todosReady, todos } = this.props;
    return(
      <div>
        <div>{settings.title}</div>
        {!todosReady && <span>Not ready</span>}
        <div>{todos.map(v=>this.renderRow(v))}</div>
      </div>
    )
  }
}

export default createContainer(params=>{
  const handle = Meteor.subscribe('todos');
  Meteor.subscribe('settings');
  return {
    todosReady: handle.ready(),
    settings: Meteor.collection('settings').findOne()
  };
}, Todo)

Connect your components

Since Meteor 1.3, createContainer is the recommended way to populate your React Components.

createContainer

Very similar to getMeteorData but your separate container components from presentational components.

Example

import Meteor, { createContainer } from 'react-web-meteor';


class Orders extends Component {
  render() {
    const { pendingOrders } = this.props;

    //...
    );
  }
}

export default createContainer(params=>{
  return {
    pendingOrders: Meteor.collection('orders').find({status: "pending"}),
  };
}, Orders)

Reactive variables

These variables can be used inside getMeteorData or createContainer. They will be populated into your component if they change.

Additionals collection methods

These methods (except update) work offline. That means that elements are correctly updated offline, and when you reconnect to ddp, Meteor calls are taken care of.

API

Meteor Collections

Meteor.subscribe

Meteor.subscribe() returns an handle. If the component which called subscribe is unmounted, the subscription is automatically canceled.

Meteor.collection(collectionName, options)

You need pass the cursoredFind option when you get your collection if you want to use cursor-like method:

Meteor.collection("collectionName", { cursoredFind: true })

Or you can simply use find() to get an array of documents. The option default to false for backward compatibility. Cursor methods are available to share code more easily between a react app and a standard Meteor app.

Meteor DDP connection

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

Availables packages

Convenience packages

Example `import { composeWithTracker } from 'react-web-meteor';``

  • EJSON
  • Tracker
  • composeWithTracker: If you want to use react-komposer, you can use react-web-meteor compatible composeWithTracker
  • Accounts (see below)

ReactiveDict

See documentation.

Meteor.Accounts

`import { Accounts } from 'react-web-meteor';``

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')
  • ...

Author

Want to help ?

Pull Requests and issues reported are welcome! :)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].