Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for data-binding to all changes in an object graph #22

Closed
kolya-ay opened this issue Dec 24, 2011 · 7 comments
Closed

Adding support for data-binding to all changes in an object graph #22

kolya-ay opened this issue Dec 24, 2011 · 7 comments

Comments

@kolya-ay
Copy link

Do you consider to add an 'elementchange' to the ArrayObservable event types in jquery.observable.js? That "change" should be fired when an element of an Array changes its value. Please take a look how it's implemented in competitive project.

@huub
Copy link

huub commented Jan 7, 2013

I am looking for the same functionality.
In my case large arrays of data are rendered by jsView; I would like to be able to detect deletions, new and changed values to post 'annotated' [deleted, new, changed] data back to the datastore.

@BorisMoore
Copy link
Owner

Yes, this is a scenario that I hope we can address more specifically, but it will be after beta, and possibly not until after V1.0. I'll get back to it then...

@BorisMoore
Copy link
Owner

I updated the title.

  • This request can address any scenarios of listening to all changes in an object graph, including your example of propertyChange of any item in an array. Possibly support paths such as a[*].b for changes of b on any item in array a, etc.

Currently much of it is already covered by 'deep data-linking', but I have considered also supporting listening to all changes. This will be much more chatty and memory intensive, though, so should only be added as a less performant opt-in scenario.

@BorisMoore
Copy link
Owner

This is largely covered now by the observeAll() feature. http://www.jsviews.com/#observeAll

@huub
Copy link

huub commented Jul 31, 2014

Great thanks, i'll refactor my code and try to use it. It has to work on one (or more) elements of an array of data), so i'll probably have to observe every element seperately?
eh.. we're you saying in April that
$.observe(person, "*", changeHandler);

would be exactly the same as
$.observable(person).observeAll( changeHandler);

@BorisMoore
Copy link
Owner

$.observe(person, "*", changeHandler); will listen to changes of any property of person, e.g. setting a new person.address object or a new person.name string, or a new person.phones array - see http://www.jsviews.com/#observe. $.observable(person).observeAll( changeHandler); will listen to the above changes, but also to changes to persons.address.street, and to adding and removing phones, or changing their values. etc.

$.observable(people).observeAll( changeHandler); will listen to adding removing items to the array etc. but also changes to people[0].address.street, people[2].phones, etc.

@BorisMoore
Copy link
Owner

I'll close this as resolved... Let me know if it does not address your requirements...

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

No branches or pull requests

3 participants