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

subview

v0.2.4

Published

A hierarchical view framework.

Downloads

5

Readme

Subview.js – Views done right! Build Status

See Website for Documentation

Subview.js is a minimalistic hierarchical view framework designed to be highly modular, highly extensible and very efficient for applications containing thousands of views. The last point makes subview an excellent choice for complex user interfaces that are redrawn often such as word processors, messengers and other single-page web-apps. Subview is not and will never be a complete MVC framework but rather a View/Controller module designed to be used in conjunction with a Data Model.

Features:

  • Extensible Views
  • Hierarchically Scoped Events
  • Elegant Templating with Your Favorite Engine (Handlebars, Underscore, EJS or Jade)
  • Efficient View Management Through Object Pools
  • Self-Contained and Compatible Any Other Framework
  • 3.4KB gzipped & 8.9KB minified

Installation

npm install subview

Basic Usage

subview('main', {

    /*** Life-Cycle Methods ***/
    once: function() {
        //Runs the first time a subview is created then never again.
    },
    init: function() {
        //Stuff to be done when initializing a subview via the .spawn method
    },
    clean: function() {
        //Runs when a subview is removed to clean and prepare it to be reused
    },

    /*** Templating ***/
    template: Handlebars.compile(myTemplate),
    subviews: {     //Subviews that will be available in the template
        name: SomeSubview
    },
    data: {         //Data available in the template (may also be a function)
        key: "value"
    },

    /*** Extensions ***/
    myExtension: myExtension({

    }),

    /*** My API ***/

    // ... Some API Functions
});

A simple example is available here.

Philosophy

Duties:

  1. Render the application
  2. Execute functions that define UI logic
  3. ~~Store application state~~ Moved to the State Extension.
  4. ~~Provide event bindings for application state change~~ Provide Event Bindings for inner-app communication.
  5. Manage View Object pools

Tenets:

  1. App interfaces should be organized into a hierarchical sub-view structure.
  2. This hierarchy should be defined only in the current state of the DOM. i.e. a subview is defined as a view that is a child of view's wrapper DOM element.
  3. These views should all inherit a set of basic methods and properties.
  4. Views should support event broadcasting.
  5. Event listeners should be directional. i.e. listen to children, parents, siblings or global.
  6. Views should be recycled automatically using an Object Pool.
  7. Templating should be supported in such a way that it can be done both server side & client side.
  8. Given a DOM element, you should be able to get it's corresponding view.
  9. No magical re-rendering of templates or DOM changes. This is essential for high-performance apps where the developer wants to control every single DOM render.
  10. Views should be able to be extended while preserving critical functionality of their parent class.

Development

To build: grunt build

To watch: grunt watch

To test: grunt test

Contributing

Contributions are always welcome! Please list bugs, issues and feature requests here.