ember-improved-cp

2.0.0 • Public • Published

Ember-improved-cp

Build Status

An addon to provide and experiment with different computed property patterns.

readOnly by default

In most cases, we likely actually want our computed properties to be readOnly. This was discussed for ember 2.0.0, but due to the potential upgrade pain it was decided against. In the future this may be reconsidered, but in the interim we can still benefit from this convention.

Today, we can easily mark any computed property as readOnly, but wouldn't it be nicer if it was the default?

You're in luck, simply import your computed properties and computed macros from the ember-improved-cp/read-only module, and you live in a readOnly by default world.

import computed, {
  readOnly
  empty
  notEmpty
  none
  not
  bool
  match
  equal
  gt
  gte
  lt
  lte
  and
  or
  any
  sum
  min
  max
  map
  sort
  setDiff
  mapBy
  filter
  filterBy
  uniq
  uniqBy
  union
  intersect
  collect
} from 'ember-improved-cp/read-only'

One example is providing defaults to components via attributes.

{{blog-component author=user.name}}
import Ember from 'ember';
import { or } from 'ember-improved-cp/read-only';

export default Ember.Component.extend({
  _defaultName: 'Anonymous Coward',
  _name: or('author', '_defaultName')
})

Installation

  • git clone <repository-url> this repository
  • cd ember-improved-cp
  • npm install
  • bower install

Running

Running Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://ember-cli.com/.

/ember-improved-cp/

    Package Sidebar

    Install

    npm i ember-improved-cp

    Weekly Downloads

    2

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    220 kB

    Total Files

    8

    Last publish

    Collaborators

    • stefanpenner