Manually recalculate "calculated properties"

If I have a custom item

Polymer({
  name: 'dane',

  computed: {
    message: 'greet(name)'
  },

  greet: function(name) {
    return 'hello ' + name + Date.now();
  }
})

When I change name, the polymer automatically recounts message, but is there a way to recount messagewithout change name?

+4
source share
1 answer

You can add another expression to express the calculation, that is:

message: 'greet(name,x)'

and then force recalculate by updating x.

Remember that the calculated properties are read-only, so you cannot directly assign a value to it.

+4
source

All Articles