Skip to content

Optionally compute field only on attribute get #38

Description

@jd-boyd

I am using backbone-computedfields for a referenced object. However, I am loaded the referenced object on demand, it isn't a pre-loaded set.

I would like for the computed field to not be calculated until its attributed is gotten with a get call. I picture this being set with a lazy key in the options dictionary for the computed field.

    computed: {
        grossPrice: {
            depends: ['netPrice', 'vatRate'],
            get: function (fields) {
                return fields.netPrice * (1 + fields.vatRate / 100);
            },
            lazy: true
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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