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

ng-backbone

v1.0.2

Published

A small extension of Backbone.js that unlocks Angular-like programming experience

Downloads

39

Readme

ngBackbone 1.0

NPM

Build Status Join the chat at https://gitter.im/dsheiko/ng-backbone

ngBackbone is a small extension of Backbone.js that unlocks Angular-like programming experience

Well, I love old good Backbone for its simplicity and flexibility. However after working with such frameworks as Angular and React, I see that Backbone app requires much more code. Yet I don't want to ditch Backbone and deal with some 20K LOC framework codebase. I just want a minimal modular extension that will improve my programming experience and maintainability of my code. And that is how I came up with ngBackbone

Motivation

What does it do?

ngBackbone extends the base with:

  • @Component decorator encapsulates declarative from imperative part of the view
  • View module binds specified models/collections to the view template (makes the template reacting on data events)
  • FormView creates state models for controls per a specified group and binds them to input/change event. FormView keeps these models in sync with element ValidityState and can run custom validators on input events.

Ng.Backbone does not depend on jQuery or Underscore, meaning you can use on an optimized build of Backbone. For example, my preferred build consists of Exoskeleton (Backbone decoupled from Underscore), Backbone.NativeView (Backbone View decoupled from jQuery) and Backbone.Fetch (Backbone.sync leveraging Feth API instead of XHR) Though Ng.Backbone works fine with canonical Backbone bundle (Backbone + jQuery + Underscore)

What does it look like?

import { Component, FormView } from "backbone-ng";
import { HeroPowers } from "./Collection/HeroPowers";

@Component({
  el: "ng-hero",
  events: {
    "submit form": "onSubmitForm"
  },
  collections: {
    powers: new HeroPowers()
  },
  template: `
    <form data-ng-group="hero">
      <div class="form-group">
        <label for="name">Name</label>
        <input id="name" name="name" type="text" class="form-control" required >
        <div class="alert alert-danger" data-ng-if="hero.name.valueMissing">
          Name is required
        </div>
      </div>
      <div class="form-group">
        <label for="power">Hero Power</label>
        <select id="power" name="power" class="form-control">
          <option data-ng-for="let aPower of powers" data-ng-text="aPower.name" >Nothing here</option>
        </select>
        <div class="alert alert-danger" data-ng-if="hero.power.dirty && !hero.power.valid">
          Power is required
        </div>
      </div>
       <button type="submit" class="btn btn-default" data-ng-prop="'disabled', !hero.group.valid">Submit</button>
    </form>
`
})

export class HeroView extends FormView {

  initialize() {
    this.collections.get( "powers" ).fetch();
  }

  onSubmitForm( e:Event ){
    e.preventDefault();
    alert( "Form submitted" )
  }

}

See more

How to

Contributing

ngBackbone welcomes maintainers. There is plenty of work to do. No big commitment required, if all you do is review a single Pull Request, you are a maintainer.

How to set up

npm install

How to run tests

npm run test