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

ember-enhanced-computed

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-enhanced-computed

Enhances the user experience of the `Ember.computed` function just a little bit.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

ember-enhanced-computed

Enhanced the user experience of the Ember.computed function just a little bit.

Installation

ember install ember-enhanced-computed

Usage

Dependent keys are passed into the function as arguments
import computed from 'ember-enhanced-computed';

let person = {
  first: 'Rob',
  last:  'Jackson',

  name: computed('first', 'last', function(first, last) {
    return `${first} ${last}`;
  })
};

person.get('name'); // => 'Rob Jackson'
get / set style is also supported
import computed from 'ember-enhanced-computed';

let person = {
  first: 'Rob',
  last:  'Jackson',

  name: computed('first', 'last', {
    get(first, last) {
      return `${first} ${last}`;
    },

    set(value /*, first, last */) {
      let [first, last] = value.split(' ');
      this.set('first', first);
      this.set('last', last);

      return value;
    }
  })
};

person.get('name'); // => 'Rob Jackson'
person.set('name', 'Stefan Penner');
person.get('name'); // => 'Stefan Penner'
When a dependent key uses the @each macro, the array before the macro is passed in
import computed from 'ember-enhanced-computed';

let crowd = {
  people: [
    { name: 'Rob Jackson' },
    { name: 'Stefan Penner' }
  ],

  names: computed('people.@each.name', function(people) {
    return people.map((person) => person.get('name'));
  });
};


crowd.get('names') // => ['Rob Jackson', 'Stefan Penner'];

'person.{first,last}' passes first and last of person as arguments

import computed from 'ember-enhanced-computed';

let post = {
  author: {
    first: 'Rob',
    last:  'Jackson',
  }

  authorName: computed('author.{first,last}', function(first, last) {
    return `${first} ${last}`;
  })
};

post.get('authorName'); // => 'Rob Jackson'

Keywords

FAQs

Package last updated on 25 Jan 2016

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