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

ember-computed-indirect

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-computed-indirect

A small addon to help declare dynamic (or indirect) computed properties.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ember-computed-indirect

This is a small Ember addon that helps deal with indirect or dynamic computed properties. What this means is that you can have one property store a reference to the property you would really like to watch, getting updates when either the referenced property or the reference changes. Example:

import computedIndirect from 'ember-computed-indirect';

var object = Ember.Object.extend({
  source1: 'value1',
  source2: 'value2',
  path: 'source1',
  value: computedIndirect('path')
}).create();

object.get('value'); // 'value1'
object.set('value', 'newvalue');
object.get('source1'); // 'newvalue'
object.set('path', 'source2');
object.get('value'); // 'value2'

There also is nothing stoping you from making the path itself a computed property:

var object = Ember.Object.extend({
  originalObject: { original: true },
  editingObject: { editing: true },

  editing: false,
  objectPath: Ember.computed('editing', function() {
    return this.get('editing') ? 'editingObject' : 'originalObject'
  },
  
  currentObject: computedIndirect('objectPath')
}).create();

object.get('currentObject'); // { original: true }
object.toggleProperty('editing');
object.get('currentObject'); // { editing: true }

Keywords

FAQs

Package last updated on 15 May 2017

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