spectate

0.0.5 • Public • Published

Watching objects with some syntactic sugar

var spectate = require("spectate");

var person = {};

spectate(person, "firstName && lastName", function (firstName, lastName) {
  console.log("Hello ", firstName, lastName); // hello Apple Bees!
});

person.firstName = "Apple";
person.lastName  = "Bees"; // triggers data-binding

API

spectator spectate(object, query, listener[, accessor])

Creates a new spectator on an object

spectator.dispose()

removes a spectator

spectator.trigger()

Triggers the listener callback

Syntax

&&

spectate(person, "firstName && lastName", listener);

||

spectate(person, "firstName || lastName", listener);

@

spectate(person, "@friends.firstName", function (friendNames) {
  console.log(friendNames); // Liam, Kevin, Oprah 
});

person.friends = [
  { firstName: "Liam"   , lastName: "Neeson"  },
  { firstName: "Kevin"  , lastName: "Spacey"  },
  { firstName: "Operah" , lastName: "Winfrey" }
];

Readme

Keywords

none

Package Sidebar

Install

npm i spectate

Weekly Downloads

0

Version

0.0.5

License

ISC

Last publish

Collaborators

  • architectd
  • crcn