diff --git a/README.md b/README.md index 57af53d..d380a28 100644 --- a/README.md +++ b/README.md @@ -168,6 +168,9 @@ Disconnect from the DDP server. * [Meteor.loginWithPassword](http://docs.meteor.com/#/full/meteor_loginwithpassword) (Please note that user is auto-resigned in - like in Meteor Web applications - thanks to React Native AsyncStorage.) * [Meteor.logout](http://docs.meteor.com/#/full/meteor_logout) * [Meteor.call](http://docs.meteor.com/#/full/meteor_call) + +## Meteor.Accounts + * [Accounts.createUser](http://docs.meteor.com/#/full/accounts_createuser) ## Meteor.ddp diff --git a/package.json b/package.json index 08d06ff..e0db945 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-meteor", - "version": "1.0.0-beta13", + "version": "1.0.0-beta14", "description": "DDP React-native Client", "main": "src/Meteor.js", "scripts": { diff --git a/src/Accounts.js b/src/Accounts.js index d767880..4a5c09c 100644 --- a/src/Accounts.js +++ b/src/Accounts.js @@ -1,8 +1,9 @@ +import call from './Call'; import User from './User'; -import Meteor from './Meteor'; -import { hashPassword } from '../utils'; +import { hashPassword } from '../lib/utils'; -export default { + +module.exports = { createUser(options, callback) { if (options.username) options.username = options.username; if (options.email) options.email = options.email; @@ -11,7 +12,7 @@ export default { options.password = hashPassword(options.password); User._startLoggingIn(); - Meteor.call("createUser", options, (err, result)=>{ + call("createUser", options, (err, result)=>{ User._endLoggingIn(); User._handleLoginCallback(err, result); diff --git a/src/Call.js b/src/Call.js new file mode 100644 index 0000000..dcdc94e --- /dev/null +++ b/src/Call.js @@ -0,0 +1,15 @@ +import Data from './Data'; + +export default function(eventName) { + var args = Array.prototype.slice.call(arguments, 1); + if (args.length && typeof args[args.length - 1] === "function") { + var callback = args.pop(); + } + + + const id = Data.ddp.method(eventName, args); + Data.calls.push({ + id: id, + callback: callback + }); +} \ No newline at end of file diff --git a/src/Meteor.js b/src/Meteor.js index 1edae84..3a65a41 100644 --- a/src/Meteor.js +++ b/src/Meteor.js @@ -11,11 +11,11 @@ import Mixin from './Mixin'; import User from './User'; import ListView from './ListView'; import collection from './Collection'; +import Accounts from './Accounts'; +import call from './Call'; - -export Accounts from './Accounts'; - -export default { +module.exports = { + Accounts: Accounts, MeteorListView: ListView, collection: collection, getData() { @@ -34,19 +34,7 @@ export default { //reason: } }, - call(eventName) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length && typeof args[args.length - 1] === "function") { - var callback = args.pop(); - } - - - const id = Data.ddp.method(eventName, args); - Data.calls.push({ - id: id, - callback: callback - }); - }, + call: call, disconnect() { if(Data.ddp) { Data.ddp.disconnect(); diff --git a/src/User.js b/src/User.js index b037f32..1d27db6 100644 --- a/src/User.js +++ b/src/User.js @@ -1,7 +1,7 @@ import { AsyncStorage } from 'react-native'; import Data from './Data'; -import { hashPassword } from '../utils'; +import { hashPassword } from '../lib/utils'; const TOKEN_KEY = 'reactnativemeteor_usertoken';