Created
September 13, 2016 08:16
-
-
Save jnsdls/a04ea08278c3fe055ae9ecc3154aa505 to your computer and use it in GitHub Desktop.
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
constructor(props, context) { | |
super(props, context); // don't forget this, no constructor without calling super() first! | |
this.state = { | |
actingUser: null, // we'll set this to the acting user later | |
photos: [], // array of existing photos we GET from the Database | |
saving: [], // unique IDs of photo's that are currently being saved | |
camera: 'front', // camera orientation ("front" or "rear") | |
offset: 0, // the offset for our database GET calls | |
canLoadMore: true, // are there more images to load from the databse? | |
currentAt: 0, // current server time, we'll set this on GET and POST calls, because we can't trust the client time | |
}; | |
// convenience functions we'll use to interact with the databse | |
// all Bebo databases are automatically namespaced for us, so we'll just call this one "photos" for our use | |
this.Db = { | |
Photos: { | |
GET: (count = 50, offset = 0) => props.bebo.Db.get('photos', {count: count, offset}), // returns a promise | |
POST: (photo) => props.bebo.Db.save('photos', photo), // returns a promise | |
}, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment