Skip to content

Conversation

vicb
Copy link

@vicb vicb commented Feb 12, 2014

I'll annotate the diff where it could help understanding. Otherwise, minor modifs.

Great work on your side !

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explains why I like the "toggle" variant.

@codelogic
Copy link
Owner

I rebased on misko's change detection, want to rebase send another pull request?

@vicb
Copy link
Author

vicb commented Feb 12, 2014

If you agree with the changes, I'll do that tomorrow

@vicb
Copy link
Author

vicb commented Feb 13, 2014

@codelogic this PR has been rebased

@vicb
Copy link
Author

vicb commented Feb 13, 2014

@codelogic any chance you can merge this today or do this need further changes ?

@codelogic
Copy link
Owner

@vicb sorry it's take me so long to get to this. After talking with Misko I rewrote a bunch of the Animate interface and how it integrates into angular at a block level, added tests for some of the pieces.

@vicb
Copy link
Author

vicb commented Feb 15, 2014

@codelogic IF you think this PR would be valuable, please let me know. Then we'll agree on a good timing for rebasing so that I don't have to rebase every other day. Thanks.

@codelogic
Copy link
Owner

@vicb I haven't contributed much to open source projects on github before, so I apologize in advance for all the rebasing and mess I'm making with the pull requests and merging as I'm stumbling through some of this. I'd love to pull in your cleanup changes, but a lot has changed since the initial PR.

@vicb
Copy link
Author

vicb commented Feb 18, 2014

@codelogic, not a problem, really. Just ping me when your branch stabilizes so that I have time to rebase and you to merge before futher major changes.

One "secret" with git is to avoid rebasing "shared" (= long running) branches. Instead of rebasing your branch on master you can merge master into your branch (or change-detector here IIRC)

@codelogic
Copy link
Owner

@vicb The branch is stable, tests have been added (and all pass the last time I ran them) and I'm waiting for feedback.

@vicb
Copy link
Author

vicb commented Feb 19, 2014

I'll check the code tomorrow morning (my time), any special point to check more carefully ?

I'll also rebase this PR.

@codelogic
Copy link
Owner

Most notably the main Animate interface is now NgAnimate (naming), and it treats everything as a list of elements instead of single elements per misko's feedback. It makes the implementation more complicated in the case of the CssAnimate implementation but it should work more efficiently for manipulating large blocks of content.

Finally, my preference would be for the toggle implementation to be separate from add and remove (even if it just forwards to add and remove) and it should include tests for the implementation.

Thanks!

@vicb
Copy link
Author

vicb commented Feb 20, 2014

@codelogic not sure if I'll have time today... more probably early next week.

I don't really understand what you mean by "the toggle implementation to be separate from add and remove " ?

@vicb
Copy link
Author

vicb commented Feb 25, 2014

@codelogic I've found time to rebase this PR, please merge if you agree with the changes. I'll have time for a deeper review tomorrow.

Could you please detail your thoughts about "toggle" (ie your previous comment). Thanks.

@vicb
Copy link
Author

vicb commented Feb 25, 2014

@codelogic one quick tip: you can enable travis ci on your repo by creating an account on https://travis-ci.org and enabling your repo in the configuration. The tests would run each time a PR is updated.

@vicb
Copy link
Author

vicb commented Feb 27, 2014

@codelogic ping ?

@codelogic codelogic merged commit 2157332 into codelogic:animate Feb 27, 2014
@vicb
Copy link
Author

vicb commented Feb 27, 2014

Thanks.

What about "Could you please detail your thoughts about "toggle" (ie your previous comment). Thanks." ?

Cheers,
Vic

@vicb vicb deleted the animate.test branch February 27, 2014 17:14
@codelogic
Copy link
Owner

I've given it a bit of thought and right now I'd like to leave addClass and removeClass separately since this is how angularJS's $animate service is written.

@vicb
Copy link
Author

vicb commented Feb 27, 2014

@codelogic don't really get what you mean

  • add and remove would remain exactly the same,
  • toggle would be added,
  • it more than often allow simplifying calling code (=syntactic sugar)

If your concern is ng.dart having toggle while ng.js don't I guess that would not be the only (the most important) API difference ?

@codelogic
Copy link
Owner

@vicb Concerns:

  • Increase in api surface only to shorten two directives, namely, ng-show and ng-hide.
  • Add an api method that will have to be implemented twice (CssAnimate does implement, not extends on NgAnimate)
  • toggle has two meanings, my first impression is that it would inspect the element, and if the class is present it would remove it, if it's not present, it would add it. I know this is not what you are intending (since you expect to provide a boolean for add/remove)
  • Inconsistent with existing list and set interfaces. Set doesn't have a 'toggle' method even though it might be convenient to 'toggle' an element in and out of a set, add and remove are more explicit.

In general, I feel toggle doesn't make the api simpler for the added complexity and inconsistency it adds.

@vicb
Copy link
Author

vicb commented Feb 27, 2014

@codelogic valid concerns, thanks for the detailed explanation.

codelogic pushed a commit that referenced this pull request May 14, 2014
-  BUG: DynamicFieldGetterFactory::isMethod did not handle methods
   defined in superclasses.
-  BUG: Upon detecting a method, the code assumed that you would only
   invoke it.  This broke application code that watched a method (e.g.
   by way of Component mapping) just to get the closurized value and
   store it somewhere to invoke later (test case and stack trace at end
   of this commit message.)
-  BUG: StaticFieldGetterFactory::method() and
   DynamicFieldGetterFactory::method() differed.  There was no
   difference between StaticFieldGetterFactory::method() and
   StaticFieldGetterFactory::getter(). 
   DynamicFieldGetterFactory::method(), as mentioned before, assumed
   that the only thing you could do with it was to invoke it (i.e. not a
   leaf watch.)
-  There was very little testing for StaticFieldGetterFactory.  This
   meant that, though it was out of sync with DynamicFieldGetterFactory,
   no tests were failing.

Changes in this commit:

- run the same tests against StaticFieldGetterFactory that are run
  against DynamicFieldGetterFactory
- do not call the result of GetterFactory.method()
  in "set object(value)"
- reduce the difference between the two different factories. 
  GetterFactory now only has one method in it's interface definition -
  the getter function.  `_MODE_METHOD_INVOKE_`, `isMethod`,
  `isMethodInvoke`, etc. are gone.

**Bug Details:**

Refer to the repro case at
chirayuk/angular.dart@issue_999^...issue_999

```dart
// Given this object.
class Foo {
  bar(x) => x+1;
}

// This test case (in an appropriate file like `scope_spec.dart`) fails
// with a traceback

it('should watch closures', (RootScope rootScope, Logger log) {
  rootScope.context['foo'] = new Foo();
  rootScope.context['func'] = null;
  rootScope.watch('foo.bar', (v, _) { rootScope.context['func'] = v; });
  rootScope.watch('func(1)', (v, o) => log([v, o]));
  rootScope.apply();
  expect(log).toEqual([[null, null], [2, null]]);
});
```

**Stack Trace:**

    Chrome 34.0.1847 (Mac OS X 10.9.2) scope watch/digest should watch closures FAILED
    Test failed: Caught Closure call with mismatched arguments: function 'DynamicFieldGetterFactory.method.<anonymous closure>'

    NoSuchMethodError: incorrect number of arguments passed to method named 'DynamicFieldGetterFactory.method.<anonymous closure>'
    Receiver: Closure: (List, Map) => dynamic
    Tried calling: DynamicFieldGetterFactory.method.<anonymous closure>(Instance of 'Foo')
    Found: DynamicFieldGetterFactory.method.<anonymous closure>(args, namedArgs)
    #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
    #1      DirtyCheckingRecord.object= (package:angular/change_detection/dirty_checking_change_detector.dart:465:78)
    dart-archive#2      _FieldHandler.acceptValue (package:angular/change_detection/watch_group.dart:630:17)
    dart-archive#3      WatchGroup.addFieldWatch (package:angular/change_detection/watch_group.dart:171:29)
    dart-archive#4      FieldReadAST.setupWatch (package:angular/change_detection/ast.dart:67:31)
    dart-archive#5      WatchGroup.watch.<anonymous closure> (package:angular/change_detection/watch_group.dart:144:40)
    dart-archive#6      _HashMap.putIfAbsent (dart:collection-patch/collection_patch.dart:124)
    dart-archive#7      WatchGroup.watch (package:angular/change_detection/watch_group.dart:143:27)
    dart-archive#8      Scope.watch (package:angular/core/scope.dart:240:31)
    dart-archive#9      main.<anonymous closure>.<anonymous closure>.<anonymous closure> (/Users/chirayu/work/angular.dart/test/core/scope_spec.dart:1308:24)
    dart-archive#10     _LocalInstanceMirror._invoke (dart:mirrors-patch/mirrors_impl.dart:440)
    dart-archive#11     _LocalInstanceMirror.invoke (dart:mirrors-patch/mirrors_impl.dart:436)
    dart-archive#12     _LocalClosureMirror.apply (dart:mirrors-patch/mirrors_impl.dart:466)
    dart-archive#13     DynamicInjector.invoke (package:di/dynamic_injector.dart:97:20)
    dart-archive#14     _SpecInjector.inject (package:angular/mock/test_injection.dart:58:22)
    dart-archive#15     inject.<anonymous closure> (package:angular/mock/test_injection.dart:100:44)
    dart-archive#16     _rootRun (dart:async/zone.dart:723)
    dart-archive#17     _ZoneDelegate.run (dart:async/zone.dart:453)
    dart-archive#18     _CustomizedZone.run (dart:async/zone.dart:663)
    dart-archive#19     runZoned (dart:async/zone.dart:954)
    dart-archive#20     _syncOuter.<anonymous closure> (package:angular/mock/zone.dart:227:22)
    dart-archive#21     _withSetup.<anonymous closure> (/Users/chirayu/work/angular.dart/test/jasmine_syntax.dart:13:14)
    dart-archive#22     _run.<anonymous closure> (package:unittest/src/test_case.dart:102:27)
    dart-archive#23     _rootRunUnary (dart:async/zone.dart:730)
    dart-archive#24     _ZoneDelegate.runUnary (dart:async/zone.dart:462)
    dart-archive#25     _CustomizedZone.runUnary (dart:async/zone.dart:667)
    dart-archive#26     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:488)
    dart-archive#27     _Future._propagateToListeners (dart:async/future_impl.dart:571)
    dart-archive#28     _Future._completeWithValue (dart:async/future_impl.dart:331)
    dart-archive#29     _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:393)
    dart-archive#30     _rootRun (dart:async/zone.dart:723)
    dart-archive#31     _ZoneDelegate.run (dart:async/zone.dart:453)
    dart-archive#32     _CustomizedZone.run (dart:async/zone.dart:663)
    dart-archive#33     _BaseZone.runGuarded (dart:async/zone.dart:574)
    dart-archive#34     _BaseZone.bindCallback.<anonymous closure> (dart:async/zone.dart:599)
    dart-archive#35     _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:23)
    dart-archive#36     _asyncRunCallback (dart:async/schedule_microtask.dart:32)
    dart-archive#37     _handleMutation (file:///Volumes/data/b/build/slave/dartium-mac-full-dev/build/src/dart/tools/dom/src/native_DOMImplementation.dart:588)

    DECLARED AT:#0      inject (package:angular/mock/test_injection.dart:97:5)
    #1      _injectify (/Users/chirayu/work/angular.dart/test/_specs.dart:236:25)
    dart-archive#2      iit (/Users/chirayu/work/angular.dart/test/_specs.dart:244:53)
    dart-archive#3      main.<anonymous closure>.<anonymous closure> (/Users/chirayu/work/angular.dart/test/core/scope_spec.dart:1305:10)
    dart-archive#4      describe.<anonymous closure> (/Users/chirayu/work/angular.dart/test/jasmine_syntax.dart:62:9)
    dart-archive#5      group (package:unittest/unittest.dart:396:9)
    dart-archive#6      describe (/Users/chirayu/work/angular.dart/test/jasmine_syntax.dart:60:15)
    dart-archive#7      describe (/Users/chirayu/work/angular.dart/test/_specs.dart:248:46)
    dart-archive#8      main.<anonymous closure> (/Users/chirayu/work/angular.dart/test/core/scope_spec.dart:1009:13)
    dart-archive#9      describe.<anonymous closure> (/Users/chirayu/work/angular.dart/test/jasmine_syntax.dart:62:9)
    dart-archive#10     group (package:unittest/unittest.dart:396:9)
    dart-archive#11     describe (/Users/chirayu/work/angular.dart/test/jasmine_syntax.dart:60:15)
    dart-archive#12     describe (/Users/chirayu/work/angular.dart/test/_specs.dart:248:46)
    dart-archive#13     main (/Users/chirayu/work/angular.dart/test/core/scope_spec.dart:14:11)
    dart-archive#14     main.<anonymous closure> (http://localhost:8765/__adapter_dart_unittest.dart:169:15)
    dart-archive#15     _rootRun (dart:async/zone.dart:723)
    dart-archive#16     _ZoneDelegate.run (dart:async/zone.dart:453)
    dart-archive#17     _CustomizedZone.run (dart:async/zone.dart:663)
    dart-archive#18     runZoned (dart:async/zone.dart:954)
    dart-archive#19     main (http://localhost:8765/__adapter_dart_unittest.dart:146:11)

    #0      _SpecInjector.inject (package:angular/mock/test_injection.dart:60:7)
    #1      inject.<anonymous closure> (package:angular/mock/test_injection.dart:100:44)
    dart-archive#2      _rootRun (dart:async/zone.dart:723)
    dart-archive#3      _rootRun (dart:async/zone.dart:724)
    dart-archive#4      _rootRun (dart:async/zone.dart:724)
    dart-archive#5      _ZoneDelegate.run (dart:async/zone.dart:453)
    dart-archive#6      _CustomizedZone.run (dart:async/zone.dart:663)
    dart-archive#7      runZoned (dart:async/zone.dart:954)
    dart-archive#8      _syncOuter.<anonymous closure> (package:angular/mock/zone.dart:227:22)
    dart-archive#9      _withSetup.<anonymous closure> (/Users/chirayu/work/angular.dart/test/jasmine_syntax.dart:13:14)
    dart-archive#10     _withSetup.<anonymous closure> (/Users/chirayu/work/angular.dart/test/jasmine_syntax.dart:14:5)
    dart-archive#11     _withSetup.<anonymous closure> (/Users/chirayu/work/angular.dart/test/jasmine_syntax.dart:14:5)
    dart-archive#12     _run.<anonymous closure> (package:unittest/src/test_case.dart:102:27)
    dart-archive#13     _rootRunUnary (dart:async/zone.dart:730)
    dart-archive#14     _ZoneDelegate.runUnary (dart:async/zone.dart:462)
    dart-archive#15     _CustomizedZone.runUnary (dart:async/zone.dart:667)
    dart-archive#16     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:488)
    dart-archive#17     _Future._propagateToListeners (dart:async/future_impl.dart:571)
    dart-archive#18     _Future._completeWithValue (dart:async/future_impl.dart:331)
    dart-archive#19     _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:393)
    dart-archive#20     _rootRun (dart:async/zone.dart:723)
    dart-archive#21     _ZoneDelegate.run (dart:async/zone.dart:453)
    dart-archive#22     _CustomizedZone.run (dart:async/zone.dart:663)
    dart-archive#23     _BaseZone.runGuarded (dart:async/zone.dart:574)
    dart-archive#24     _BaseZone.bindCallback.<anonymous closure> (dart:async/zone.dart:599)
    dart-archive#25     _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:23)
    dart-archive#26     _asyncRunCallback (dart:async/schedule_microtask.dart:32)
    dart-archive#27     _handleMutation (file:///Volumes/data/b/build/slave/dartium-mac-full-dev/build/src/dart/tools/dom/src/native_DOMImplementation.dart:588)

Closes dart-archive#999
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

Successfully merging this pull request may close these issues.

2 participants