Code Monkey home page Code Monkey logo

auto-computed's Introduction

Ember Decorators

npm version Build Status

Ember Decorators began as a project dedicated to exploring and unlocking the future of native classes in Ember.js. Now, that future is here! Decorators will be landing soon in Ember, and there is a polyfill available for them.

This library now contains a few extra decorators which were not upstreamed to Ember, and may still be useful to some users. Check out the documentation website for detailed API documentation for all the decorators included in this addon.

Usage

First install the main ember-decorators addon.

ember install ember-decorators

This addon doesn't contain any decorators itself, but includes the core set of subaddons that are necessary to begin writing Ember using native classes:

  • @ember-decorators/component
  • @ember-decorators/object

See the API Documentation for detailed examples and documentation of the individual decorators.

Development

Specs

Ember follows the legacy decorators "stage 1" proposal API. The decorators proposal is currently being redesigned for stage 3, and the champions have publicly stated that this is the recommended path forward.

Organization

This repository consists of multiple packages managed with lerna.js. The decorators all reside in their own individual packages under /packages, along with the main ember-decorators package.

The main package serves three purposes:

  1. A quick way to install all of the subpackages and get new projects up and running. Installing the main package also adds any necessary babel transforms, and sets up ESLint properly.
  2. A place for common functionality, such as the native class blueprints that overwrite the default Ember blueprints.
  3. A place for the documentation site and tests for all of the other addons. Tests were consolidated from the other addons in order to speed up the testing and development process.

Setting up

  • Fork the repository
  • git clone <your-fork-url>
  • cd ember-decorators
  • npm install

Linting

  • npm run lint:js
  • npm run lint:js -- --fix

Running tests

  • npm test โ€“ Runs the test suite on the current Ember version

Running the dummy application

License

This project is licensed under the MIT License.

auto-computed's People

Contributors

danielspaniel avatar ember-tomster avatar pzuraq avatar snewcomer avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

auto-computed's Issues

ember 3.1.0 beta breaks auto computed

I could submit a PR, but all you have to do is update package of ember-source to 3.1.0-beta.4 and the test

auto computed properties: dependent key changes invalidate the computed property
fails ..

I am available all weekend to help fix it. ๐Ÿ˜„

I bumped up @ember-decorators/utils to 2.0.0-beta.4 and that has a few differences ( like no more extractValue ) .. so have been noodling around with that update in this repo as well ( which I think is necessary too )

Feature Request: Allow composition of computed decorators

For feature parity with ember-macro-helpers and ember-awesome-macros.

This works:

import EmberObject from 'ember-object';

import or from 'ember-awesome-macros/or';
import computed from 'ember-macro-helpers/computed';

export default EmberObject.extend({
  foo: computed(or('bar', 'qux'), function(barOrQux) {
  })
});

This, sadly, does not:

import EmberObject from 'ember-object';

import computed, { or } from 'ember-computed-decorators';

export default EmberObject.extend({
  @computed @or('bar', 'qux') // or @computed(or(..))
  foo(barOrQux) {
  }
});

This works (with kellyselden/ember-awesome-macros#348):

import EmberObject from 'ember-object';

import mapBy from 'ember-awesome-macros/array/map-by';
import sum from 'ember-awesome-macros/sum';
import raw from 'ember-macro-helpers/raw';

export default EmberObject.extend({
  items: [],
  
  totalQuantity: sum(mapBy('items', raw('quantity')))
});

This, sadly, does not:

import EmberObject from 'ember-object';

import { mapBy, sum } from 'ember-computed-decorators';

export default EmberObject.extend({
  items: [],

  @sum @mapBy('items', 'quantity') // or @sum(mapBy(..))
  totalQuantity
});

Does this still work with ember-decorators 5.0 +

I tried to upgrade to ember-decorators 5 and things got weird ( using auto computed allot ). I guess I can make a PR where I update ember-decorators/utils and show you what i mean. But not sure why this addon was never updated. Is this because you guys not favor it or don't use it much?

Question: compatibility with es6 getters

While I, of course, love this addon, and the style of computed it offers:

If I do this:

export default class ExampleComponent extends Component {
  @autoComputed('someKey', 'otherKey')
  bar(someKey, otherKey) {
    return `${someKey} - ${otherKey}`;
  }
}

Is this going to be compatible with the way ember is removing the need for using get to call a computed property?
In other words, if I use auto-computed style will I be able to do:

this.bar 

within the component or will I be forced to do:

this.get('bar'); 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.