Path
Handles watching a scope for simple and complex paths.
For example, here are some simple expressions:
title
count > 10
isLoggedIn ? "Log out" : "Log in"
user.name
These create a simple list of "edges":
[ 'title' ]
[ 'count' ]
[ 'isLoggedIn' ]
[ 'user', 'user.name' ]
Those edges can then be used as keys to point to an accessor. You can then attach event listeners to the accessors. What's important is that, a scope has a bunch of accessors, which are stored by the edge/key above (so like { 'user.name': accessor }
).
You can swap out data without having to recreate anything or modify any event listeners. This is ideal for performance. This means that a scope + accessor is a shell for data.
Here are some complex expressions where the path dynamically changes based on something inside of the []
square brackets:
user[attr.name]
For these ones, if attr
or attr.name
changes, user[attr.name]
might evaluate to a totally new property. So this Path
module helps abstract this all away for you.
Install
node:
$ npm install expressionjs-path
browser:
$ component install expressionjs/path
Licence
MIT