
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
angular-collection-assistant
Advanced tools
Helper service to handle Angular collection update events via $watchCollection
Small, dependency free module to help manage collection events when using $watchCollection
within Angular.
Use bower to install into a project:
bower install angular-collection-assistant
Then check there is a reference to the script file in your header:
<script src="/bower_components/angular/angular.min.js"></script>
<script src="/bower_components/angular-collection-assistant/ng-collection-assistant.js"></script>
Finally bring in the module into your main app:
var app = angular.module("app", [
'ngResource',
'ng-collection-assistant'
]);
You can now use the collectionAssistant object in your controllers:
app.controller('widgetController', function($scope, collectionAssistant, Products) {
$scope.products = Products.query({});
$scope.$watchCollection('products', function(newProducts, oldProducts) {
collectionAssistant(newProducts, oldProducts)
.on('new', function(item) {
console.log('New item discovered from server!', item);
});
});
}
// Somewhere inside an Angular Controller
$scope.products = [
{
id: 'product-foo',
title: 'Foo',
},
{
id: 'product-bar',
title: 'Bar',
},
{
id: 'product-baz',
title: 'Baz',
}
];
$scope.$watchCollection('products', function(newProducts, oldProducts) {
collectionAssistant(newProducts, oldProducts)
.indexBy('id')
.on('new', function(item) {
console.log('New Item!', item);
});
.on('deleted', function(item) {
console.log('Deleted Item!', item);
})
.on('finally', $scope.redraw);
});
Enabling deep comparison also allows update detection of individual collection items:
$scope.$watchCollection('products', function(newProducts, oldProducts) {
collectionAssistant(newProducts, oldProducts)
.indexBy('id')
.deepComparison()
.on('new', function(item) {
console.log('New Item!', item);
});
.on('deleted', function(item) {
console.log('Deleted Item!', item);
})
.on('update', function(item, oldItem) {
console.log('Item', item, 'has changed from', oldItem);
});
});
FAQs
Helper service to handle Angular collection update events via $watchCollection
The npm package angular-collection-assistant receives a total of 0 weekly downloads. As such, angular-collection-assistant popularity was classified as not popular.
We found that angular-collection-assistant demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.