Table of Contents
import Meteor from '@ajaybhatia/react-native-meteor';
Connect to the Meteor Server
url: The URL of your Meteor Server websocket. This should typically start with ws://
(insecure, like http://
) or wss://
(secure, like https://
), and have the path /websocket
, e.g.: wss://myapp.meteor.com/websocket
options:
- 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.
- AsyncStorage object your preferred AsyncStorage. Defaults to
'@react-native-async-storage/async-storage'
as a peer dependency.
Disconnect from the Meteor server
Perform a call to a method
Subscribe to a collection
Returns the logged in user
Access the meteor users collection
Returns the userId of the logged in user
Gets the current connection status. Returns an object with the following properties:
connected: Boolean
status: "connected" || "disconnected"
Returns true if attempting to login
import { withTracker, useTracker } from '@ajaybhatia/react-native-meteor'
;
Creates a new Tracker
Arguments:
- trackerFunc - Function which will be re-run reactively when it's dependencies are updated. Must return an object that is passed as properties to
Component
- Component - React Component which will receive properties from trackerFunc
Creates a new Tracker React Hook. Can only be used inside a function component. See React Docs for more info.
Arguments:
- trackerFunc - Function which will be re-run reactively when it's dependencies are updated.
import { ReactiveDict } from '@ajaybhatia/react-native-meteor'
Creates a new reactive dictionary
ReactiveDict Methods:
- .get(key) - Gets value of key (Reactive)
- .set(key, value) - Sets value of key
import { Mongo } from '@ajaybhatia/react-native-meteor';
Creates and returns a Collection
Arguments
- collectionName - Name of the remote collection, or pass
null
for a client-side collection
Collection Methods:
- .insert(document) - Inserts document into collection
- .update(query, modifications) - Updates document in collection
- .remove(query) - Removes document from collection
- .find(query) =>
Cursor
- Returns a Cursor - .findOne(query) => Document - Retrieves first matching Document
Cursor Methods:
- .obsrve() - Mirrors Meteor's observe behavior. Accepts object with the properties
added
,changed
, andremoved
. - .fetch() =>
[Document]
- Retrieves an array of matching documents
import { Accounts } from '@ajaybhatia/react-native-meteor';
Creates a user
Arguments
- user - The user object
- callback - Called with a single error object or null on success
Changes a user's password
Arguments
- oldPassword - The user's current password
- newPassword - The user's new password
Registers a callback to be called when user is logged in
Arguments
- callback
Registers a callback to be called when login fails
Arguments
- callback
Hashes a password using the sha-256 algorithm. Returns an object formatted for use in accounts calls. You can access the raw hashed string using the digest property.
Arguments
- plaintext - The plaintext string you want to hash
Other:
import { enableVerbose } from '@ajaybhatia/react-native-meteor';
Verbose Mode logs detailed information from various places around MeteorRN. Note: this will expose login tokens and other private information to the console.
Enables verbose mode