1- import invariant from 'invariant'
2- import promisify from '../utils/promisify'
3- import { Base , ReferenceBase } from './base'
1+ import invariant from 'invariant' ;
2+ import { promisify } from '../utils' ;
3+ import { Base , ReferenceBase } from './base' ;
44
55class PresenceRef extends ReferenceBase {
66 constructor ( presence , ref , pathParts ) {
@@ -18,33 +18,33 @@ class PresenceRef extends ReferenceBase {
1818 }
1919
2020 setOnline ( ) {
21- this . ref . setAt ( { online : true } )
21+ this . ref . setAt ( { online : true } ) ;
2222 this . _connectedRef . on ( 'value' , ( snapshot ) => {
2323 const val = snapshot . val ( ) ;
2424 if ( val ) {
2525 // add self to connection list
2626 // this.ref.push()
2727 this . ref . setAt ( {
28- online : true
29- } )
30- . then ( ( ) => {
31- this . _disconnect ( ) ;
32-
33- this . _onConnect . forEach ( fn => {
34- if ( fn && typeof fn === 'function' ) {
35- fn . bind ( this ) ( this . ref ) ;
36- }
37- } )
28+ online : true ,
3829 } )
30+ . then ( ( ) => {
31+ this . _disconnect ( ) ;
32+
33+ this . _onConnect . forEach ( ( fn ) => {
34+ if ( fn && typeof fn === 'function' ) {
35+ fn . bind ( this ) ( this . ref ) ;
36+ }
37+ } ) ;
38+ } ) ;
3939 }
4040 } ) ;
4141 return this ;
4242 }
4343
4444 setOffline ( ) {
4545 if ( this . ref ) {
46- this . ref . setAt ( { online : false } )
47- . then ( ( ) => this . ref . off ( 'value' ) )
46+ this . ref . setAt ( { online : false } )
47+ . then ( ( ) => this . ref . off ( 'value' ) ) ;
4848 this . presence . off ( this . _pathParts ) ;
4949 }
5050 return this ;
@@ -53,10 +53,10 @@ class PresenceRef extends ReferenceBase {
5353 _disconnect ( ) {
5454 if ( this . ref ) {
5555 this . ref . onDisconnect ( )
56- . setValue ( { online : false } ) ;
56+ . setValue ( { online : false } ) ;
5757 // set last online time
5858 this . lastOnlineRef . onDisconnect ( )
59- . setValue ( this . firestack . ServerValue . TIMESTAMP )
59+ . setValue ( this . firestack . ServerValue . TIMESTAMP ) ;
6060 }
6161 }
6262
@@ -72,7 +72,7 @@ class PresenceRef extends ReferenceBase {
7272}
7373
7474export default class Presence extends Base {
75- constructor ( firestack , options = { } ) {
75+ constructor ( firestack , options = { } ) {
7676 super ( firestack , options ) ;
7777
7878 this . instances = { } ;
@@ -85,7 +85,7 @@ export default class Presence extends Base {
8585 const pathKey = this . _presenceKey ( path ) ;
8686 if ( ! this . instances [ pathKey ] ) {
8787 const _ref = this . firestack . database . ref ( pathKey ) ;
88- this . log . debug ( 'Created new presence object for ' , pathKey )
88+ this . log . debug ( 'Created new presence object for ' , pathKey ) ;
8989 const inst = new PresenceRef ( this , _ref , path ) ;
9090
9191 this . instances [ pathKey ] = inst ;
@@ -110,6 +110,6 @@ export default class Presence extends Base {
110110 }
111111
112112 get namespace ( ) {
113- return 'firestack:presence'
113+ return 'firestack:presence' ;
114114 }
115115}
0 commit comments