An addon to provide and experiment with different computed property patterns.
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.
import Ember from 'ember';
import { or } from 'ember-improved-cp/read-only';
export default Ember.Component.extend({
_defaultName: 'Anonymous Coward',
_name: or('author', '_defaultName')
})
git clone <repository-url>
this repositorycd ember-improved-cp
npm install
bower install
ember serve
- Visit your app at http://localhost:4200.
npm test
(Runsember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli, visit http://ember-cli.com/.