Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
ember-computed-change-gate
Advanced tools
[![Build Status](https://travis-ci.org/GavinJoyce/ember-computed-change-gate.svg)](https://travis-ci.org/GavinJoyce/ember-computed-change-gate)
Observers on Ember.js computed properties are fired if a dependant key changes, regardless of whether the property value changes or not. ember-computed-change-gate
only triggers observers when the result of a computed property changes.
Consider the following example:
Ember.Object.extend({
name: 'Gavin',
trimmedName: function() {
return this.get('name').trim();
}.property('name'),
onTrimmedNameChanged: function() {
console.log('trimmedName changed');
}.observes('trimmedName')
});
Every time name
changes onTrimmedNameChanged
will be run, even if the value of trimmedName
doesn't change.
import changeGate from 'ember-computed-change-gate/change-gate';
Ember.Object.extend({
name: 'Gavin',
trimmedName: changeGate('name', function(value) {
return value.trim();
}),
onTrimmedNameChanged: function() {
console.log('trimmedName changed');
}.observes('trimmedName')
});
Using changeGate
will prevent the onTrimmedNameChanged
observer from firing unless the value of trimmedName
changes. Please see the video below for an example of how I've used this when building Intercom:
Questions? Ping me @gavinjoyce
git clone
this repositorynpm install
bower install
ember server
FAQs
Create computed properties which trigger observers only if the value of the computed property has changed
We found that ember-computed-change-gate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.