func (fb *Firebase) Watch(notifications chan Event) error {
	fb.watchMtx.Lock()
	if fb.watching {
		fb.watchMtx.Unlock()
		close(notifications)
		return nil
	}
	fb.watching = true
	fb.watchMtx.Unlock()
	stop := make(chan struct{})
	events, err := fb.watch(stop)
	if err != nil {
		return err
	}
	var closedManually bool
	go func() {
		<-fb.stopWatching
		closedManually = true
		stop <- struct{}{}
	}()
	go func() {
		defer close(notifications)
		for event := range events {
			if closedManually {
				return
			}
			notifications <- event
		}
	}()
	return nil
}
Watch listens for changes on a firebase instance and
passes over to the given chan.

Only one connection can be established at a time. The
second call to this function without a call to fb.StopWatching
will close the channel given and return nil immediately.
package firego
import (
	"bufio"
	"bytes"
	"encoding/json"
	"errors"
	"log"
	"net/http"
	"time"
)
const (
	EventTypePut = "put"
	EventTypePatch = "patch"
	EventTypeError = "event_error"
	EventTypeAuthRevoked = "auth_revoked"
	eventTypeKeepAlive  = "keep-alive"
	eventTypeCancel     = "cancel"
	eventTypeRulesDebug = "rules_debug"
)
type Event struct {
	Type string
	Path string
	Data interface{}
	rawData []byte
}
func (e Event) Value(v interface{}) error {
	var tmp struct {
		Data interface{} `json:"data"`
	}
	tmp.Data = &v
	return json.Unmarshal(e.rawData, &tmp)
}
func (fb *Firebase) StopWatching() {
	fb.watchMtx.Lock()
	defer fb.watchMtx.Unlock()
	if fb.watching {
		fb.watching = false
		fb.stopWatching <- struct{}{}
	}
}
func (fb *Firebase) setWatching(v bool) {
	fb.watchMtx.Lock()
	fb.watching = v
	fb.watchMtx.Unlock()
}