SteveSanderson / knockout-es5

Knockout.js meets ECMAScript 5 properties
158 stars 39 forks source link

Add recursion #24

Closed jbblanchet closed 9 years ago

jbblanchet commented 9 years ago

I understand that the non-recursion is by design, but I have an use case where it would be pretty useful. In a spa, I'm receiving a complex object from an API, and I want to be able to make it observable quickly. Adding and option to crawl the object recursively would be really helpful. I have a proof of concept working, and the changes appear rather minimal. I can give it a go, but I'd like to make sure that it something that would be considered first.

archangel-irk commented 9 years ago

Recursive traversal will be added in the near future.

unsafecode commented 9 years ago

+1

archangel-irk commented 9 years ago

Recursion added bcf8f67555160b73ec1cf2912e99bee6b9c7d20b

Use:

ko.track( obj, { deep: true } );

fields param:

ko.track(obj, { deep: true, fields: ['prop1', 'prop2'] })
unsafecode commented 9 years ago

Thanks, wonderful!

archangel-irk commented 9 years ago

Notice: Selecting of nested fields (e.g. 'prop.nested_prop') are not yet supported. If someone need this feature, please create an issue.