File tree Expand file tree Collapse file tree 2 files changed +51
-9
lines changed Expand file tree Collapse file tree 2 files changed +51
-9
lines changed Original file line number Diff line number Diff line change @@ -48,15 +48,6 @@ export class ProtoWatchGroup {
4848 return watchGroup ;
4949 }
5050
51- /**
52- * Sets the context (the object) on which the change detection expressions will
53- * dereference themselves on. Since the WatchGroup can be reused the context
54- * can be re-set many times during the lifetime of the WatchGroup.
55- *
56- * @param context the new context for change dection for the curren WatchGroup
57- */
58- setContext ( context ) {
59- }
6051}
6152
6253export class WatchGroup {
@@ -79,6 +70,15 @@ export class WatchGroup {
7970 /// IMPLEMENT
8071 }
8172
73+ /**
74+ * Sets the context (the object) on which the change detection expressions will
75+ * dereference themselves on. Since the WatchGroup can be reused the context
76+ * can be re-set many times during the lifetime of the WatchGroup.
77+ *
78+ * @param context the new context for change dection for the curren WatchGroup
79+ */
80+ setContext ( context ) {
81+ }
8282}
8383
8484export class WatchGroupDispatcher {
Original file line number Diff line number Diff line change 1+ import { describe , it , expect } from 'test_lib/test_lib' ;
2+ import { ProtoWatchGroup , WatchGroup , WatchGroupDispatcher } from 'change_detection/watch_group' ;
3+ import { DOM } from 'facade/dom' ;
4+
5+
6+ export function main ( ) {
7+ describe ( 'change_detection' , function ( ) {
8+ describe ( 'ChangeDetection' , function ( ) {
9+ it ( 'should do simple watching' , function ( ) {
10+ return ; // remove me after getting the test to pass.
11+ var person = new Person ( 'misko' , 38 ) ;
12+ var pwg = new ProtoWatchGroup ( ) ;
13+ pwg . watch ( 'name' , 'nameToken' ) ;
14+ pwg . watch ( 'age' , 'ageToken' ) ;
15+ var dispatcher = new LoggingDispatcher ( ) ;
16+ var wg = pwg . instantiate ( dispatcher ) ;
17+ wg . setContext ( person ) ;
18+ var cd = new ChangeDetection ( wg ) ;
19+ cd . detectChanges ( ) ;
20+ expect ( dispatcher . log ) . toEqual ( [ 'ageToken=38' ] ) ;
21+ dispatcher . clear ( ) ;
22+ cd . detectChanges ( ) ;
23+ expect ( dispatcher . log ) . toEqual ( [ ] ) ;
24+ person . age = 1 ;
25+ person . name = "Misko" ;
26+ cd . detectChanges ( ) ;
27+ expect ( dispatcher . log ) . toEqual ( [ 'nameToken=Misko' , 'ageToken=1' ] ) ;
28+ } ) ;
29+ } ) ;
30+ } ) ;
31+ }
32+
33+ class Person {
34+ constructor ( name :string , age :number ) {
35+ this . name = null ;
36+ this . a
37+ }
38+ }
39+
40+ class Dispatcher extends WatchGroupDispatcher {
41+
42+ }
You can’t perform that action at this time.
0 commit comments