0.0.5 • Published 9 years ago

spectate v0.0.5

Weekly downloads
5
License
ISC
Repository
github
Last release
9 years ago

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" }
];
0.0.5

9 years ago

0.0.4

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago