Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-computed-change-gate

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-computed-change-gate

[![Build Status](https://travis-ci.org/GavinJoyce/ember-computed-change-gate.svg)](https://travis-ci.org/GavinJoyce/ember-computed-change-gate)

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ember-computed-change-gate

Build Status

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:

Watch a screencast showing how this addon was built below

Image

Questions? Ping me @gavinjoyce

Development Instructions

  • git clone this repository
  • npm install
  • bower install

Running

Keywords

FAQs

Package last updated on 08 Nov 2014

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc