|
1 |
| -## Meteor |
| 1 | +# Meteor React Native Docs |
| 2 | + |
| 3 | +Table of Contents |
| 4 | +- [Meteor](#meteor) |
| 5 | +- [Tracker](#tracker) |
| 6 | + |
| 7 | +<h2 id="meteor">Meteor</h2> |
2 | 8 | `import Meteor from '@meteorrn/core';`
|
3 | 9 |
|
| 10 | + |
4 | 11 | ### `Meteor.connect(url, options)`
|
5 | 12 | Connect to the Meteor Server
|
6 | 13 |
|
@@ -46,60 +53,123 @@ Returns true if attempting to login
|
46 | 53 |
|
47 | 54 | ### `Meteor.logoutOtherClients`
|
48 | 55 |
|
49 |
| -## withTracker |
50 |
| -`import { withTracker } from '@meteorrn/core'`; |
51 | 56 |
|
52 |
| -The `withTracker` component is used the same way as [`meteor/react-meteor-data`](https://guide.meteor.com/react.html#using-withTracker) |
53 | 57 |
|
54 |
| -```javascript |
55 |
| -export default withTracker(() => { |
56 |
| - let handle = Meteor.subscribe("mySubscription"); |
57 |
| - let loading = !handle.ready(); |
58 |
| - let myStuff = Stuff.find({}).fetch(); |
59 |
| - |
60 |
| - return { |
61 |
| - myStuff |
62 |
| - }; |
63 |
| -})(MyComponent); |
64 |
| -``` |
| 58 | +<h2 id="tracker">Tracker</h2> |
| 59 | +`import { withTracker, useTracker } from '@meteorrn/core'`; |
| 60 | + |
| 61 | + |
| 62 | +#### `withTracker(trackerFunc)(Component)` |
| 63 | +Creates a new Tracker |
| 64 | + |
| 65 | +**Arguments:** |
| 66 | + * 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` |
| 67 | + * Component - React Component which will receive properties from trackerFunc |
| 68 | + |
| 69 | + |
| 70 | +#### `useTracker(trackerFunc)` => `React Hook` |
| 71 | +Creates a new Tracker React Hook. Can only be used inside a function component. See React Docs for more info. |
| 72 | + |
| 73 | +**Arguments:** |
| 74 | + * trackerFunc - Function which will be re-run reactively when it's dependencies are updated. |
| 75 | + |
| 76 | + |
65 | 77 |
|
66 | 78 | ## ReactiveDict
|
67 | 79 | `import { ReactiveDict } from '@meteorrn/core'`
|
68 | 80 |
|
69 |
| -https://atmospherejs.com/meteor/reactive-dict |
| 81 | +#### `new ReactiveDict()` => *`ReactiveDict`* |
| 82 | +Creates a new reactive dictionary |
| 83 | + |
| 84 | + |
| 85 | +#### *`ReactiveDict`* |
| 86 | + |
| 87 | +***ReactiveDict* Methods:** |
| 88 | + * .get(key) - Gets value of key (Reactive) |
| 89 | + * .set(key, value) - Sets value of key |
| 90 | + |
70 | 91 |
|
71 | 92 |
|
72 | 93 | ## Mongo
|
73 | 94 | `import { Mongo } from '@meteorrn/core';`
|
74 | 95 |
|
75 |
| -#### `Mongo.Collection(collectionName, options)` |
76 |
| -*collectionName*: Name of the remote collection, or pass `null` for a client-side collection |
| 96 | +#### `new Mongo.Collection(collectionName, options)` => `Collection` |
| 97 | +Creates and returns a *Collection* |
77 | 98 |
|
78 |
| -**options**: |
79 |
| - * [.insert(doc, callback)](http://docs.meteor.com/#/full/insert) |
80 |
| - * [.update(id, modifier, [options], [callback])](http://docs.meteor.com/#/full/update) |
81 |
| - * [.remove(id, callback(err, countRemoved))](http://docs.meteor.com/#/full/remove) |
| 99 | +**Arguments** |
| 100 | + * collectionName - Name of the remote collection, or pass `null` for a client-side collection |
| 101 | + |
| 102 | + |
| 103 | +#### *`Collection`* |
| 104 | + |
| 105 | +***Collection* Methods:** |
| 106 | + * .insert(document) - Inserts document into collection |
| 107 | + * .update(query, modifications) - Updates document in collection |
| 108 | + * .remove(query) - Removes document from collection |
| 109 | + * .find(query) => *`Cursor`* - Returns a Cursor |
| 110 | + * .findOne(query) => Document - Retrieves first matching Document |
| 111 | + |
| 112 | + |
| 113 | +#### *`Cursor`* |
| 114 | + |
| 115 | +***Cursor* Methods:** |
| 116 | + * .obsrve() - Mirrors Meteor's observe behavior. Accepts object with the properties `added`, `changed`, and `removed`. |
| 117 | + * .fetch() => `[Document]` - Retrieves an array of matching documents |
82 | 118 |
|
83 |
| -#### *Cursor*.observe |
84 |
| -Mirrors Meteor's observe behavior. Accepts object with the properties `added`, `changed`, and `removed`. |
85 | 119 |
|
86 | 120 |
|
87 | 121 | ## Accounts
|
88 | 122 | `import { Accounts } from '@meteorrn/core';`
|
89 | 123 |
|
90 |
| -* [Accounts.createUser](http://docs.meteor.com/#/full/accounts_createuser) |
91 |
| -* [Accounts.changePassword](http://docs.meteor.com/#/full/accounts_forgotpassword) |
| 124 | + |
| 125 | +#### `Accounts.createUser(user, callback)` |
| 126 | +Creates a user |
| 127 | + |
| 128 | +**Arguments** |
| 129 | + * user - The user object |
| 130 | + * callback - Called with a single error object or null on success |
| 131 | + |
| 132 | + |
| 133 | +#### `Accounts.changePassword(oldPassword, newPassword)` |
| 134 | +Changes a user's password |
| 135 | + |
| 136 | +**Arguments** |
| 137 | + * oldPassword - The user's current password |
| 138 | + * newPassword - The user's new password |
| 139 | + |
| 140 | + |
| 141 | +#### `Accounts.onLogin(callback)` |
| 142 | +Registers a callback to be called when user is logged in |
| 143 | + |
| 144 | +**Arguments** |
| 145 | + * callback |
| 146 | + |
| 147 | + |
| 148 | +#### `Accounts.onLoginFailure(callback)` |
| 149 | +Registers a callback to be called when login fails |
| 150 | + |
| 151 | +**Arguments** |
| 152 | + * callback |
| 153 | + |
| 154 | + |
| 155 | +#### `Accounts._hashPassword(plaintext)` => `{algorithm:"sha-256", digest:"..."}` |
| 156 | +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. |
| 157 | + |
| 158 | +**Arguments** |
| 159 | + * plaintext - The plaintext string you want to hash |
| 160 | + |
| 161 | +Other: |
| 162 | + |
92 | 163 | * [Accounts.forgotPassword](http://docs.meteor.com/#/full/accounts_changepassword)
|
93 | 164 | * [Accounts.resetPassword](http://docs.meteor.com/#/full/accounts_resetpassword)
|
94 |
| -* [Accounts.onLogin](http://docs.meteor.com/#/full/accounts_onlogin) |
95 |
| -* [Accounts.onLoginFailure](http://docs.meteor.com/#/full/accounts_onloginfailure) |
96 |
| -* `Accounts._hashPassword` - SHA-256 hashes password, for use with methods that may require authentication |
97 | 165 |
|
98 |
| -## enableVerbose |
| 166 | + |
| 167 | + |
| 168 | +## Verbosity |
99 | 169 | `import { enableVerbose } from '@meteorrn/core';`
|
100 | 170 |
|
101 |
| -Enables verbose mode which logs detailed information about accounts. **Note:** this will expose login tokens and other private information to the console. |
| 171 | +Verbose Mode logs detailed information from various places around MeteorRN. **Note:** this will expose login tokens and other private information to the console. |
| 172 | + |
102 | 173 |
|
103 |
| -```` |
104 |
| -enableVerbose() |
105 |
| -```` |
| 174 | +#### `enableVerbose()` |
| 175 | +Enables verbose mode |
0 commit comments