Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/peerlibrary/meteor-data-lookup
Reactively lookup a field in the object
https://github.com/peerlibrary/meteor-data-lookup
meteor meteor-package
Last synced: about 1 month ago
JSON representation
Reactively lookup a field in the object
- Host: GitHub
- URL: https://github.com/peerlibrary/meteor-data-lookup
- Owner: peerlibrary
- License: bsd-3-clause
- Created: 2015-12-26T11:55:49.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-09-20T04:20:35.000Z (over 5 years ago)
- Last Synced: 2024-11-09T06:06:03.363Z (3 months ago)
- Topics: meteor, meteor-package
- Language: CoffeeScript
- Homepage: https://atmospherejs.com/peerlibrary/data-lookup
- Size: 4.88 KB
- Stars: 2
- Watchers: 6
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
data lookup
===========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](http://www.meteor.com/) application adds `DataLookup` class
into the global scope.Both client and server side.
Installation
------------```
meteor add peerlibrary:data-lookup
```API
---`DataLookup` provides the following static methods:
* `lookup(obj, path)` – resolves the value by traversing the `obj` object using the `path`; if `path` 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 called
* `get(obj, path, equalsFunc)` - same as `lookup`, but if called inside a reactive computation, it uses
[ComputedField](https://github.com/peerlibrary/meteor-computed-field) 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 use `equalsFunc` to use a different equality function to determine when the value has changed