Live queries from event queries occur in the background

Previously, LIVE queries as a result of an  EVENT query would not be sent to the current connection. Now any LIVE queries resulting from an EVENT query will be delivered to ALL connections, regardless of where it originated.
This commit is contained in:
Tobie Morgan Hitchcock 2020-02-17 13:46:54 +00:00
parent 180ab61207
commit e57a088688
2 changed files with 6 additions and 0 deletions

View file

@ -65,6 +65,10 @@ func (d *document) event(ctx context.Context, met method) (err error) {
kind = "DELETE" kind = "DELETE"
} }
var id = d.i.e.id
d.i.e.id = d.i.e.id + "-bg"
defer func() { d.i.e.id = id }()
vars := data.New() vars := data.New()
vars.Set(d.id, varKeyThis) vars.Set(d.id, varKeyThis)
vars.Set(kind, varKeyMethod) vars.Set(kind, varKeyMethod)

View file

@ -41,6 +41,7 @@ type socket struct {
func clear(id string) { func clear(id string) {
go func() { go func() {
sockets.Range(func(key, val interface{}) bool { sockets.Range(func(key, val interface{}) bool {
val.(*socket).clear(id + "-bg")
val.(*socket).clear(id) val.(*socket).clear(id)
return true return true
}) })
@ -50,6 +51,7 @@ func clear(id string) {
func flush(id string) { func flush(id string) {
go func() { go func() {
sockets.Range(func(key, val interface{}) bool { sockets.Range(func(key, val interface{}) bool {
val.(*socket).flush(id + "-bg")
val.(*socket).flush(id) val.(*socket).flush(id)
return true return true
}) })