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

Commit

Permalink
fix(scope): allow sending emit/broadcast when no on()
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Feb 20, 2014
1 parent c3f9395 commit d9dfe0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/core/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ class _Streams {
ScopeEvent event = new ScopeEvent(name, scope, data);
Scope scopeCursor = scope;
while(scopeCursor != null) {
if (scopeCursor._streams._scope == scopeCursor) {
if (scopeCursor._streams !=null &&
scopeCursor._streams._scope == scopeCursor) {
ScopeStream stream = scopeCursor._streams._streams[name];
if (stream != null) {
event._currentScope = scopeCursor;
Expand Down
6 changes: 6 additions & 0 deletions test/core/scope_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ main() => describe('scope', () {
describe(r'events', () {

describe('on', () {
it('should allow emit/broadcast when no listeners', inject((RootScope scope) {
scope.emit('foo');
scope.broadcast('foo');
}));


it(r'should add listener for both emit and broadcast events', inject((RootScope rootScope) {
var log = '',
child = rootScope.createChild();
Expand Down

0 comments on commit d9dfe0f

Please sign in to comment.