0
votes

Does firebase provide reference attribute concept?

If I want to notify my online status (online | offline | away) status to all my friends list where I am part of, one easy to implement is to define reference attribute say user@status and if its value is changed it could trigger change status where ever it is defined. Can this be achieved in Firebase?

I am trying to implement chat user status updates. We have user list maintained

Users/user-id-1/[user-id(friend),name,online-status],[user-id(friend),name,online-status], ...

Users/user-id-2/[user-id(friend),name,online-status],[user-id(friend),name,online-status], ...

If a particular user comes online then currently we need to update his status to all their users manually in a loop so that they get status updates...

Is there a better way to implement such backend triggers where if one field is changed update other fields... Can we define such rules or define some kind of reference pointers?

1

1 Answers

0
votes
users
   uid_1234
     email: [email protected]
     online: true
  uid_5678
     email: [email protected]
     online: false

Each user observes the users node for changes.

When a user logs on, set the online status to true. All other users will be notified that this users status changed and can update their UI accordingly.

Side note: add a onDisonnect observer to a users online status node when they log on to set it to false upon disconnect.