Skip to content

Proper support for composable properties #96

@cibernox

Description

@cibernox

This is a long term plan for adding proper support to composable computed properties in a more efficient way.

There was a proposal that ended in a no-go by the core team. You can checkout this commit and search for Ember.FEATURES.isEnabled('composable-computed-properties') in the source code to see the original implementation.

The key difference with the current implementation is in the way computed properties that receive other computed properties subscribe to changes.

  • In this repo when a macro receives another macro as arguments, it inspects the dependencies of those computed properties and sets them as dependencies of the new macros. See https://github.com/cibernox/ember-cpm/blob/master/addon/utils.js#L38
  • The original approach is more efficient. Whenever an anonymous macros is created, it is registered in the global Ember namespace with a unique name (its guid). Therefore, when a macro receives a computed macros to compose the only thing it has to do is watch that key in the global Ember space.

This approach is more efficient since it sets up much less watches and also simplifies the code of the macros considerably. Also, should be more resilent to changes in ember itself, since it does not need to use private APIs of the computed properties.

The downside of this approach is that it can't be achieved completely from the plugins (I think), since it requires some changes in the guts of ember itself, by example in defineProperty (see this).

Therefore, to get this approach working a bit of bureaucracy will be necessary, either convince the core team to allow anonymous computed properties to be registered in the global namespace, or to provide a few extension points in key points of the core to allow to customize how thinks like defineProperty works.

Eventually the ultimate goal could be to offer a composable-compatible version to every macro built in ember to, eventually in ember 2.0, remove all computed properties from the core of ember (and therefore slim it of non superfluos) and let them live here.

/cc @truenorth @hjdivad

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions