Table of Contents
import Meteor from '@meteorrn/core';
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. - reachabilityUrl string ["https://clients3.google.com/generate_204"] server to check internet reachability, used by NetInfo. If not provided, NetInfos default url will be used, which currently is
'https://clients3.google.com/generate_204'
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
Returns true if attempting to logout
Logs a user in. If selector is a string containing @, then this will be interpreted as an email, other strings as a username. The selector can also be an object with a single key email, id or username.
The optional Callback is called with a single Error argument on failure.
If 2fa is enabled, the error property of the argument may be no-2fa-code. Read more in the Meteor docs
Logs a user in, same as loginWithPassword, but providing a 2fa token via the argument code. Read more on this in the Meteor docs.
import { withTracker, useTracker } from '@meteorrn/core';
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 '@meteorrn/core'
Creates a new reactive dictionary
ReactiveDict Methods:
- .get(key) - Gets value of key (Reactive)
- .set(key, value) - Sets value of key
import { Mongo } from '@meteorrn/core';
Creates and returns a Collection
Arguments
- collectionName - Name of the remote collection, or pass
nullfor 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 '@meteorrn/core';
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
Checks if the current user has 2fa enabled, via callback; cf. the meteor docs
Arguments
- callback - Called with an error on the first argument, e.g. if the user is currently not logged in, and a boolean result on the second argument, if the user has 2fa enabled.
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 '@meteorrn/core';
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