This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Removed from snippet for brevity | |
*/ | |
import DDPClient from 'ddp-client'; | |
let ddpClient = new DDPClient(); | |
export default React.createClass({ | |
getInitialState() { | |
return { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Removed from snippet for brevity | |
*/ | |
componentDidMount() { | |
ddpClient.connect((err, wasReconnect) => { | |
let connected = true; | |
if (err) connected = false; | |
this.setState({ connected: connected }); | |
this.makeSubscription(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Removed from snippet for brevity | |
*/ | |
export default React.createClass({ | |
getInitialState() { | |
return { | |
connected: false, | |
posts: {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handleIncrement() { | |
ddpClient.call('addPost'); | |
}, | |
handleDecrement() { | |
ddpClient.call('deletePost'); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RNApp/app/ddp.js | |
import DDPClient from 'ddp-client'; | |
let ddpClient = new DDPClient(); | |
ddpClient.signUpWithEmail = (email, password, cb) => { | |
let params = { | |
email: email, | |
password: password | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RNApp/app/ddp.js | |
/* | |
* Removed from snippet for brevity | |
*/ | |
ddpClient.loginWithEmail = (email, password, cb) => { | |
let params = { | |
user: { | |
email: email |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RNApp/app/ddp.js | |
/* | |
* Removed from snippet for brevity | |
*/ | |
ddpClient.loginWithUsername = (username, password, cb) => { | |
let params = { | |
user: { | |
username: username |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RNApp/app/ddp.js | |
import DDPClient from 'ddp-client'; | |
import { AsyncStorage } from 'react-native'; | |
/* | |
* Removed from snippet for brevity | |
*/ | |
ddpClient.onAuthResponse = (err, res) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RNApp/app/ddp.js | |
/* | |
* Removed from snippet for brevity | |
*/ | |
ddpClient.loginWithToken = (loginToken, cb) => { | |
let params = { resume: loginToken }; | |
return ddpClient.call("login", [params], cb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// RNApp/app/ddp.js | |
/* | |
* Removed from snippet for brevity | |
*/ | |
ddpClient.logout = (cb) => { | |
AsyncStorage.multiRemove(['userId', 'loginToken', 'loginTokenExpires']). | |
then((res) => { | |
ddpClient.call("logout", [], cb) |