Skip to content

Using observeAll with a filter #472

@BrentH-Alnico

Description

@BrentH-Alnico

Hi Boris,

I couldn't find a sample using a filter with observeAll...its got me a bit confused ;-) https://www.jsviews.com/#observeAll@filter

Case #⁠1 root props are passed through name (unexpected) while objects/arrays address are not (expected).
Are root props filterable?...they pass through in all cases below.

$.observable(person).observeAll(changeHandler, function (path, object, parentObs) {
   return false; // Does not prevent root props from passing through
});

Case #⁠2 root.address passes through (expected) while root.phones[] or root.phones[0] does not (unexpected).

if (path == 'root.address' || path == "root.phones[]" ) {
   return true;
}
return false;

Case #⁠3 both root.address and root.phones[] are not passed through (expected) while root.address2 is passed through (expected).
Notice that path root.phones[] works here, but not in the above case.

if (path == 'root.address' || path == "root.phones[]" ) {
   return false;
}
return true;

Here is one of your examples slightly modified for testing: https://jsfiddle.net/alnico/t3fv5ngk/1/

My use case (case #⁠3) using a filter, is to listen to all 'business data' changes that would enable a 'Send' button, while excluding UI opened/closed state data, etc.
I have much more business data than other...thus I would like to use this as an exclusion filter.

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