Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Unstable watched collections should trigger 'Model unstable' error #633

Closed
pavelgj opened this issue Feb 26, 2014 · 2 comments
Closed

Unstable watched collections should trigger 'Model unstable' error #633

pavelgj opened this issue Feb 26, 2014 · 2 comments
Milestone

Comments

@pavelgj
Copy link
Contributor

pavelgj commented Feb 26, 2014

Right now they trigger Observer reaction functions should not change model.

@vicb vicb self-assigned this Mar 3, 2014
@vicb vicb added this to the v0.9.9 milestone Mar 3, 2014
@vicb vicb removed their assignment Mar 3, 2014
@matsko matsko modified the milestones: 0.9.10, v0.9.9 Mar 10, 2014
@jbdeboer jbdeboer self-assigned this Mar 19, 2014
@jbdeboer
Copy link
Contributor

This was fixes, it seems.

iit('should throw assertion on unstable model', (RootScope rootScope, Logger log) {
          // Generates a different, equal, list on each evaluation.
          rootScope.context['list'] = new UnstableList();

          rootScope.watch('list.list', (n, v) => log(n));
          rootScope.digest();
        });

class UnstableList {
  List get list => new List.generate(3, (i) => i);
}

returns

Test failed: Caught Model did not stabilize in 5 digests. Last 3 iterations:
    list.list: [0, 1, 2] <= [0, 1, 2]
    list.list: [0, 1, 2] <= [0, 1, 2]
    list.list: [0, 1, 2] <= [0, 1, 2]

which looks like what we are expecting.

I'm not checking this test in since we already have similar ones.

@pavelgj
Copy link
Contributor Author

pavelgj commented Mar 19, 2014

No, here's the test case:

      iit('should throw "model unstable" error when observer is present', (RootScope rootScope, NgZone zone, ExceptionHandler e) {
        // Generates a different, equal, list on each evaluation.
        rootScope.context['list'] = new UnstableList();

        rootScope.watch('list.list', (n, v) => null, readOnly: true);
        try {
          zone.run(() => null);
        } catch(_) {}

        var errors = (e as LoggingExceptionHandler).errors;
        expect(errors.length).toEqual(1);
        expect(errors.first.error, startsWith('Model did not stabilize'));
      });

class UnstableList {
  List get list => new List.generate(3, (i) => i);
}

@pavelgj pavelgj reopened this Mar 19, 2014
@vicb vicb modified the milestones: 0.11.0, 0.10.0 Mar 20, 2014
@mhevery mhevery assigned chirayuk and unassigned jbdeboer Apr 2, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants