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

Commit d9dfe0f

Browse files
committed
fix(scope): allow sending emit/broadcast when no on()
1 parent c3f9395 commit d9dfe0f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/core/scope.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,8 @@ class _Streams {
409409
ScopeEvent event = new ScopeEvent(name, scope, data);
410410
Scope scopeCursor = scope;
411411
while(scopeCursor != null) {
412-
if (scopeCursor._streams._scope == scopeCursor) {
412+
if (scopeCursor._streams !=null &&
413+
scopeCursor._streams._scope == scopeCursor) {
413414
ScopeStream stream = scopeCursor._streams._streams[name];
414415
if (stream != null) {
415416
event._currentScope = scopeCursor;

test/core/scope_spec.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ main() => describe('scope', () {
216216
describe(r'events', () {
217217

218218
describe('on', () {
219+
it('should allow emit/broadcast when no listeners', inject((RootScope scope) {
220+
scope.emit('foo');
221+
scope.broadcast('foo');
222+
}));
223+
224+
219225
it(r'should add listener for both emit and broadcast events', inject((RootScope rootScope) {
220226
var log = '',
221227
child = rootScope.createChild();

0 commit comments

Comments
 (0)