Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

ento

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ento

Simple, stateful, observable objects in JavaScript.

latest
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

ento.js

Simple, stateful, observable objects in JavaScript. Yet another model library, but this one aims to make the API experience as close to plain JavaScript objects as possible.

var User = Ento()
  .attr('id', Number)
  .attr('firstName')
  .attr('lastName');

me = new User({ firstName: 'John', lastName: 'Coltrane' });

me.firstName = 'Jacques';
me.first_name;

m.on('change', function (attrs) { ... });
  • Plain attributes: ECMAScript getters and setters are used to listen for updates in attributes. No need for methods like .get() and .set().

  • Change tracking: Listen for changes in instances via .on('change').

  • Custom sync: No persistence is built in (AJAX, SQL, etc). Implement it however you need it.

  • Model states: Keeps track of your model's state if it's fetching, or got an error. This is useful when used with data-binding view libraries.

  • Browser or Node.js: Reuse the same business code in your client-side libs and your server-side libs.

"Ento" is the Esperanto transation of the word "entity."

Status

API overview

Computed properties: you can define properties that are derived from other properties.

var Person = Ento()
  .attr('firstName')
  .attr('lastName')
  .attr('fullName', ['firstName', 'lastName'], function () {
    return [this.firstName, this.lastName].join(' ');
  });

var me = new User({ firstName: "Miles", lastName: "Davis" });

me.fullName;
=> "Miles Davis"

Plugins, and instance methods: create methods via use().

var Car = Ento()
  .use(Ento.persistence) // plugins
  .use(Ento.validation)
  .use({
    start: function () { ... },
    drive: function () { ... }
  });

var civic = new Car();
civic.start();

See the documentation for even more features.

What's it like?

  • It's like Ember.Object, except decoupled from any MVC library.
  • It's like Backbone.Model, but less emphasis on collections.
  • It's like Spine.Model, but with change tracking.
  • It's like Modella, but with collections. (You should probably try Modella, actually.)
  • It's like all of the above, with simpler syntax, and a use-only-what-you-need approach.

Acknowledgements

Contains code from Backbone.js.

Backbone's MIT license goes here

FAQs

Package last updated on 11 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts