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

immutable-angular

v0.1.2

Published

Support for ImmutableJS collections in Angular 1.x

Downloads

134

Readme

immutable-angular

Support for watching and enumerating immutable-js collections in Angular 1.x

Build Status

Getting started

  1. Install immutable-angular using npm or jspm

    npm install immutable-angular
    jspm install npm:immutable-angular
  2. Include the 'immutable' module as a dependency of your module

    import 'immutable-angular';
    
    angular.module('myModule', ['immutable-angular']);
  3. Iterate over and watch Immutable structures

    import Immutable from 'immutable';
    
    class SomethingController {
    
        static get $inject() { return ['$scope']; }
    
        constructor($scope) {
            this.list = Immutable.List([1, 2, 3]);
            $scope.$watchImmutable(() => this.list, () => this.listChanged());
        }
    
        listChanged() {
            // ...
        }
    }
    <ul>
        <li repeat-immutable="item in something.list">{{item}}</li>
    </ul>

How it works

$watchImmutable()

$watchImmutable(watchExpression: function | string, listener: function)

$watchImmutable allows for the watching of Immutable data structures with dirty checking based on the Immutable.is() function. It will compile watchExpression to a getter and then delegate to the original $watch() using a wrapper getter which only returns a new result if Immutable.is() reports a change in the value.

Source

repeat-immutable

repeat-immutable currently only supports basic iteration syntax:

<li repeat-immutable="item in list">...</li>

although more complex configuration will likely be introduced as needs arise. repeat-immutable will track object values by attaching a non-enumerable, non-writable GUID identifier. Objects with the same structure are permitted, as they will be assigned different identifiers. Including the same object reference multiple times in a single list is currently not allowed as it will marked as handled on each iteration pass at the first reference. Similarly, primitive values are tracked by identity and therefore repeated values are not allowed.

Source

Motivation

Angular's ng-repeat directive is not capable of iterating data structures which are not plain arrays or objects. Furthermore, ng-repeat uses the $watchCollection() function which sets up watchers not only for the collection but also for each item in the collection in case the collection is mutated. In the case that our collections are immutable, we should only be watching for changes to the reference to the collection itself. Additionally, we should not be converting to plain JS objects every time we need to re-render as Immutable data structures are easily iterable on their own.

Development

Install gulp globally

npm install -g gulp

To bundle sources to the dist directory:

gulp bundle

To run tests and linting:

gulp test

To generate API documentation:

gulp docs