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

Cannot ignore observable arrays #28

Open
jrsearles opened this issue Aug 7, 2015 · 3 comments
Open

Cannot ignore observable arrays #28

jrsearles opened this issue Aug 7, 2015 · 3 comments

Comments

@jrsearles
Copy link

It's currently not possible to ignore an observable array within a hierarchy. (The code-path for arrays never does this check.)

Also instead of having a "beta" file would you consider making a separate alpha branch?

@ZiadJ
Copy link
Owner

ZiadJ commented Sep 3, 2015

Can you post some sample code to better illustrate the issue?

As for the alpha branch I'm not sure I'll need one since I'm not really planning to add any big new features in the near future unless you have anything to propose.

@kailashsingh
Copy link

kailashsingh commented Jul 8, 2016

I too was facing similar issue where I wanted to pause ObservableArray using watch API but it doesnt work.
To make it work, I made the following changes in knockout.reactor.js (Version 1.3.6)

Solution: Check watchable condition even for array change events in 'assignWatcher' API

/************** code snippet **************/ API: assignWatcher
child.subscribe(function (changes) {
if (child.watchable !== false) {
ko.utils.arrayForEach(changes, function (item) {
var returnValue = evaluatorCallback.call(context, parents, child, item);
if (returnValue !== undefined) context(returnValue);

                        if (!item.moved) {
                            // Deleted or brand new item. Unwatch or watch it accordingly.
                            setTimeout(function () {
                                watchChildren(item.value, (keepOffParentList ? null : child), parents, item.status === 'deleted');
                            }, 0);
                        }
                    });
                }
            }, undefined, 'arrayChange')._watcher = context;

/********************************************/

@ZiadJ
Copy link
Owner

ZiadJ commented Jul 9, 2016

Ok, thanks for the update @kailashsingh . I'll make the necessary changes when time permits.

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

No branches or pull requests

3 participants