title: Firebase update on disconnect
body: <p>I have a node on firebase that lists all the players in the game. This list will update as and when new players join. And when the current user ( me ) disconnects, I would like to remove myself from the list.</p>
  
  <p>As the list will change over time, at the moment I disconnect, I would like to update this list and update firebase.</p>
  
  <p>This is the way I am thinking of doing it, but it doesn't work as .update doesnt accept a function. Only the object. But if I create the object beforehand, when .onDisconnect calls, it will not be the latest object... How should I go about doing this?</p>
  
  <pre><code>payload.onDisconnect().update( () =&gt; {
              const withoutMe = state.roomObj
              const index = withoutMe.players.indexOf( state.userObj.name )
              if ( index &gt; -1 ) {
                  withoutMe.players.splice( index, 1 )
              }
              return withoutMe
          })
  </code></pre>