GithubHelp home page GithubHelp logo

Comments (5)

stefanpenner avatar stefanpenner commented on May 22, 2024

We don't plan to support this here, as the plan is for volatile to merely be a raw es5 getter

from ember-decorators.

blia avatar blia commented on May 22, 2024

@stefanpenner Ok. It's rightly. Thanks.

from ember-decorators.

blia avatar blia commented on May 22, 2024

Maybe some mode with memorize decorator?
What do you think of it? Discussed?

from ember-decorators.

stevesims avatar stevesims commented on May 22, 2024

@stefanpenner I just tried to use a raw es5 getter to make what's effectively a volatile CP within a component but found that when the getter code is run this is the raw JS object for the component definition, rather than the run-time instance of the component, thus this.get and this.getProperties are not defined.

The old style syntax of Ember.computed(function() {}).volatile() as per the example above works OK. Given the syntax of how a component is currently made (using Ember.Component.extend(...)) it makes sense that an es5 getter won't work, and an old style volatile CP will, but it feels a bit icky to have to use old-style computed syntax alongside decorators.

Feels like it would be nice to have a @volatile, at least in the short term

from ember-decorators.

rwjblue avatar rwjblue commented on May 22, 2024

Kind of annoying, but you cannot use the ES6 shorthand for defining getters/setters at .extend time right now.

// does not work
export default Ember.Component.extend({
  get foo() {
    return 'hi';
  }
});
// Works, but definitely not as pretty:
const Thing = Ember.Component.extend({});

Object.defineProperty(Thing.prototype, 'foo', {
  get() {
    return 'hi';
  }
});

export default Thing;

Small demo: http://rwjblue.jsbin.com/bofijik/edit?html,js,output

from ember-decorators.

Related Issues (20)

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.