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-steroids-change-detector

v0.3.0

Published

[![Build Status](https://travis-ci.org/wishtack/ng-steroids.svg?branch=develop)](https://travis-ci.org/wishtack/ng-steroids) [![Greenkeeper badge](https://badges.greenkeeper.io/wishtack/ng-steroids.svg)](https://greenkeeper.io/)

Downloads

11

Readme

Build Status Greenkeeper badge

Angular 2+ Change Detector for AngularJS 1.5.x

The idea here is to benefit from the Angular 2 OnPush mode in AngularJS.

Suppose you have a component like this one:

class UserPreviewComponent {
    
    config = {
        bindings: {
            user: '<'
        },
        controller: UserPreviewComponent,
        template: `<div>{{ $ctrl.user.firstName }}</div>`
    }
    
}

const module = angular.module('...', []);

module.component('userPreview', UserPreviewComponent.config);

That we use like this:


<div ng-repeat="user in $ctrl.userList">
    <user-preview user="user"></user-preview>
</div>

The classical problem is that we'll end up with 2 * N + 1 watchers where N is the user count. And if we had 10 watchers per component, we would end up with 11 * N + 1 watchers.

Luckily, we have one-time-binding and we can one-time-bind everything and end up with 0 watchers. But what if users can be updated? Are we forced to watch everything? What about enabling the watch explicitly per component only when the user reference changes (not it's properties)... YES ! Immutability !

Using the ng-steroids-change-detector module you can implement this behaviour as if you were already using Angular 2.

Install

yarn add ng-steroids-change-detector

Import required polyfills

import 'core-js/es6/array';
import 'core-js/es6/set';

Usage

1 - Add the dist/change-detector.min.js to your app or if import it if you are using webpack.

2 - Add the AngularJS module dependency to your modules:

angular.module('...', [
    'wishtack.steroids.changeDetector'
])

3 - Inject the ChangeDetector in your component.

class UserPreviewComponent {
    
    config = {
        bindings: {
            user: '<'
        },
        controller: UserPreviewComponent,
        template: `<div>{{ $ctrl.user.firstName }}</div>`
    }
    
    private _changeDetector;
    
    constructor($scope, ChangeDetector) {
        'ngInject';
        
        this._changeDetector = new ChangeDetector({scope: $scope});
        
    }
    
}

This will automatically disable the component's watchers except if the reference to the user input changes.

4 - Changes can also be triggered manually using:

this._changeDetector.markForCheck();