Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Computed properties #4

Closed
gr0uch opened this issue Nov 23, 2015 · 1 comment
Closed

Computed properties #4

gr0uch opened this issue Nov 23, 2015 · 1 comment

Comments

@gr0uch
Copy link
Owner

gr0uch commented Nov 23, 2015

Not sure if this is possible but worth investigating, use user-defined getter/setters in the bound data object.

var store = {}
var data = {}

Object.defineProperty(data, 'computed', {
  get: function () { return store.computed }
  set: function (x) { store.computed = x + x }
})

var node = bind(data, bindings)

Would need to use Object.getOwnPropertyDescriptor.

@gr0uch
Copy link
Owner Author

gr0uch commented Nov 23, 2015

After trying to implement this, I realized that it is not possible, due to the setter function needing its own closure.

@gr0uch gr0uch closed this as completed Nov 23, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant