I'm working on login system and need to watch if user is logged in / out. The value which determines user login status is returned in following way:
Parse.User.current().id // returns id when logged in
Parse.User.current() // returns null when logged out
expected functionality (pseudocode):
watch( Parse.User.current().id, function (old_val, new_val) {
console.log( 'User id has changed from: ', old_val, ' to: ', new_val );
});
// expected result: User id has changed from null to H4tn34vw0
I would like to keep wide browser support, like ie9+. I considered Object.observe()
but it can watch object properties, not values returned by methods if i'm correct. Also using setInterval()
and checking the object every second may not be a good idea for performance.
Aucun commentaire:
Enregistrer un commentaire