This repository was archived by the owner on Feb 22, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -513,15 +513,19 @@ class _Streams {
513
513
scope = queue.removeFirst ();
514
514
scopeStreams = scope._streams;
515
515
assert (scopeStreams._scope == scope);
516
- assert (scopeStreams._streams.containsKey (name));
517
- var stream = scopeStreams._streams[name];
518
- event._currentScope = scope;
519
- stream._fire (event);
516
+ if (scopeStreams._streams.containsKey (name)) {
517
+ var stream = scopeStreams._streams[name];
518
+ event._currentScope = scope;
519
+ stream._fire (event);
520
+ }
520
521
// Reverse traversal so that when the queue is read it is correct order.
521
522
var childScope = scope._childTail;
522
523
while (childScope != null ) {
523
524
scopeStreams = childScope._streams;
524
- if (scopeStreams != null ) queue.addFirst (scopeStreams._scope);
525
+ if (scopeStreams != null &&
526
+ scopeStreams._typeCounts.containsKey (name)) {
527
+ queue.addFirst (scopeStreams._scope);
528
+ }
525
529
childScope = childScope._prev;
526
530
}
527
531
}
Original file line number Diff line number Diff line change @@ -448,6 +448,19 @@ main() => describe('scope', () {
448
448
expect (result.name).toBe ('some' );
449
449
expect (result.targetScope).toBe (child1);
450
450
}));
451
+
452
+
453
+ it ('should skip scopes which dont have given event' ,
454
+ inject ((RootScope rootScope, Logger log) {
455
+ var child1 = rootScope.createChild ('A' );
456
+ rootScope.createChild ('A1' );
457
+ rootScope.createChild ('A2' );
458
+ rootScope.createChild ('A3' );
459
+ var child2 = rootScope.createChild ('B' );
460
+ child2.on ('event' ).listen ((e) => log (e.data));
461
+ rootScope.broadcast ('event' , 'OK' );
462
+ expect (log).toEqual (['OK' ]);
463
+ }));
451
464
});
452
465
453
466
You can’t perform that action at this time.
0 commit comments