This Meteor smart package provides a reactive lookup of a field in the object.
It matches the behavior of the lookup in Spacebars, so {{foo.bar}}
resolves
the same as DataLookup.get(dataContext, 'foo.bar')
.
Adding this package to your Meteor application adds DataLookup
class
into the global scope.
Both client and server side.
meteor add peerlibrary:data-lookup
DataLookup
provides the following static methods:
lookup(obj, path)
– resolves the value by traversing theobj
object using thepath
; ifpath
is a string, it is first split on.
; if a value is not found,undefined
is returned; if any value on path is a function, it is first calledget(obj, path, equalsFunc)
- same aslookup
, but if called inside a reactive computation, it uses ComputedField to minimize invalidations so that the reactive computation is invalided only when the value looked up itself changes, and not every time the input object changes; you can useequalsFunc
to use a different equality function to determine when the value has changed