diff options
Diffstat (limited to 'client/object/object.go')
| -rw-r--r-- | client/object/object.go | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/client/object/object.go b/client/object/object.go index 2e0d83b..a3404cc 100644 --- a/client/object/object.go +++ b/client/object/object.go @@ -17,7 +17,7 @@ type cacheEntry struct { type ObjStream interface { Sub(id string) - GetInfo(id string, callback func(proto.Command)) + GetInfo(id string, callback func(*proto.Object)) Unsub(id string) } @@ -36,13 +36,7 @@ func (oc *ObjCache) Get(id string) *proto.Object { func (oc *ObjCache) Fetch(id string, callback func(*proto.Object)) { entry := oc.objects[id] if !entry.cached { - oc.stream.GetInfo(id, func(cmd proto.Command) { - if cmd.Kind == "i" && len(cmd.Args) > 0 { - callback(&cmd.Args[0]) - } else { - callback(nil) - } - }) + oc.stream.GetInfo(id, callback) } else { callback(&entry.o) } @@ -70,6 +64,10 @@ func (oc *ObjCache) Unwatch(id string) { } } +func (oc *ObjCache) IsWatched(id string) bool { + return oc.objects[id].refCount > 0 +} + func (oc *ObjCache) Update(id string, new proto.Object) { entry := oc.objects[id] if entry.cached && new.Kind == entry.o.Kind { |
