npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

doobie

v0.1.0

Published

A minimalist two-way data-binding library for those who don't need big fat frameworks like Angular.js.

Downloads

8

Readme

A minimalist two-way data-binding library for those that are looking for something leaner than big fat frameworks like Angular.js.

How to install

bower install --save doobie

Or if you're using npm:

npm install --save doobie

Just include it in your HTML file. You will also need to include jQuery before including this library:

<script src="jquery.js" />
<script src="doobie.js" />

Then all that you have to do is invoke $.doobie() and pass your model to the library:

$.doobie({
    firstName: 'Foo',
    lastName: 'von Bar',
    fullName: function(firstName, lastName) {
        return this.firstName + ' ' + this.lastName;
    }
});

And then, in your HTML, reference your model using doobie attributes. See below.

One-way data-binding (model -> view)

For instance:

<p doobie="firstName"></p>

The <p> element's content will immediately be filled with the value from firstName and every time it changes. It works with every element that is a container.

Two-way data-binding (model <-> view)

If you bind it to an <input> tag, it will work as a two-way binding. Any update to the <input> will also trigger an update to the property, and vice-versa:

<input type="text" doobie="lastName" />

It works for textarea elements too. select is on the roadmap yet.

Computed properties

For cases that you want to bind to the DOM some processed version of the model you have, you should use a computed property. It allows you to specify a function that will be called every time some of its dependencies change. For example, say you have the following model:

$.doobie({
    firstName: 'Foo',
    lastName: 'von Bar',
    fullName: function(firstName, lastName) {
        return this.firstName + ' ' + this.lastName;
    }
});

And then your HTML has a div like this:

Your name is <span doobie="fullName"></span>.

Doobie watches for those function's parameters and parses them as properties of your model. So, every time at least one of those properties change, your function is called to update DOM elements that are bound to it.

Arrays

It is a very common pattern to map an array to rows in a table in HTML. In general, you may want to map an array to a list of any element type. To be able to do that, you can the same attribute doobie that you use for other bindings. The DOM will be kept up to date with the array every time an item is added, updated or removed from it.

Array elements themselves can contain other objects, even other arrays, and the binding will still work as expected.