yarn add meteorjs-client
or
npm i --save meteorjs-client
Should be done only once.
Use the wss protocol for connecting to secure deployments with ssl.
Meteor.connect('wss://example.com:3000/websocket')Use the ws protocol for insecure connections, e.g. during development.
Meteor.connect('192.168.1.23')Meteor.disconnect()import Meteor, {withTracker} from 'meteorjs-client'
import SomeComponent from './SomeComponent'
function trackerFunction({listId}) {
const stuffHandle = Meteor.subscribe('stuffInList', listId)
const listHandle = Meteor.subscribe('aList', listId)
const stuff = Meteor.collection('stuff').find({listId})
const list = Meteor.collection('list').findOne(listId)
return {
listReady: listHandle.ready(),
list,
stuffReady: stuffHandle.ready(),
stuff,
}
}
export default withTracker(trackerFunction)(SomeComponent)Here SomeComponent will receive stuffReady and stuff props. Unlike standard Meteor there is no need to call fetch as find returns an array.
import {show} from './my-popup-alerts'
Meteor.call('arrive', function(err) {
if (err) {
show('Error clocking in')
}
})Meteor.loginWithPassword(username, password, (err) => {
this.setState({loggingIn: false})
if (err) {
this.setState({loginError: true})
}
})const user = Meteor.user()
const userId = Meteor.userId()
console.log(`User is ${user ? user.username : 'Not logged in'}`)
const loggedIn = !!userId
const authToken = Meteor.getAuthToken()Easily check if we are logging in.
const loggingIn = Meteor.loggingIn()Are we currently connected to the server.
const {connected, status} = Meteor.status()I have used react-native-meteor for some years in production. However, it is not being kept upto date and stopped me updating to newer react-native versions. This fork was created to stay up to date with changes in react, also reducing the size of the library removing non essential parts. This will aid the process of staying upto date.
The idea is to have a core js library with implementations for React, Vue, React Native e.t.c. That's the plan lets see how we do
Pull Requests and issues reported are welcome! :)
meteorjs-client is MIT Licensed.