Skip to content

Commit

Permalink
Update to dart libraries 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
marcojakob committed Nov 11, 2013
1 parent d5e9b7f commit ca03f63
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Changelog
================

## Version 0.2.4 (2013-11-11) ##
* Update to dart libraries 0.9.0.

## Version 0.2.3 (2013-09-16) ##
* Fix issue #8: Add logging of events that flow through event bus

Expand Down
41 changes: 26 additions & 15 deletions example/event_bus_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@ import 'dart:html';

import 'dart:async';
import 'events.dart' as events;
import 'package:logging_handlers/logging_handlers_shared.dart';
import 'package:intl/intl.dart';
import 'package:logging/logging.dart';

int counterA = 1;
int counterB = 1;

void main() {
// Init logging.
Logger.root.onRecord.listen(new PrintHandler().call);
Logger.root.level = Level.FINEST;
initLogging();

// Initialize the global event bus.
events.init(new events.LoggingEventBus());

// Initialize the listener boxes.
Listener listener1 = new Listener(query('#listener-1'));
Listener listener2 = new Listener(query('#listener-2'));
Listener listener1 = new Listener(querySelector('#listener-1'));
Listener listener2 = new Listener(querySelector('#listener-2'));

// Init Event fields.
LabelElement fireLabelA = query('#fire-label-a');
LabelElement fireLabelB = query('#fire-label-b');
ButtonElement fireButtonA = query("#fire-button-a");
ButtonElement fireButtonB = query("#fire-button-b");
LabelElement fireLabelA = querySelector('#fire-label-a');
LabelElement fireLabelB = querySelector('#fire-label-b');
ButtonElement fireButtonA = querySelector("#fire-button-a");
ButtonElement fireButtonB = querySelector("#fire-button-b");

fireButtonA.onClick.listen((_) {
// -------------------------------------------------
Expand All @@ -46,6 +45,18 @@ void main() {
});
}

initLogging() {
DateFormat dateFormat = new DateFormat('yyyy.mm.dd HH:mm:ss.SSS');

// Print output to console.
Logger.root.onRecord.listen((LogRecord r) {
print('${dateFormat.format(r.time)}\t${r.loggerName}\t[${r.level.name}]:\t${r.message}');
});

// Root logger level.
Logger.root.level = Level.FINEST;
}

class Listener {
Element element;

Expand All @@ -54,13 +65,13 @@ class Listener {
StreamSubscription<String> subscription;

Listener(this.element) {
output = element.query('textarea');
output = element.querySelector('textarea');
// Init buttons.
element.query('.listen-a').onClick.listen((_) => listenForEventA());
element.query('.listen-b').onClick.listen((_) => listenForEventB());
element.query('.pause').onClick.listen((_) => pause());
element.query('.resume').onClick.listen((_) => resume());
element.query('.cancel').onClick.listen((_) => cancel());
element.querySelector('.listen-a').onClick.listen((_) => listenForEventA());
element.querySelector('.listen-b').onClick.listen((_) => listenForEventB());
element.querySelector('.pause').onClick.listen((_) => pause());
element.querySelector('.resume').onClick.listen((_) => resume());
element.querySelector('.cancel').onClick.listen((_) => cancel());
}

void listenForEventA() {
Expand Down
10 changes: 5 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: event_bus
version: 0.2.3
version: 0.2.4
author: Marco Jakob <majakob@gmx.ch>
description: A simple Event Bus using Dart Streams for decoupling applications
homepage: https://github.com/marcojakob/dart-event-bus
documentation: http://edu.makery.ch/projects/dart-event-bus
dependencies:
logging: any
intl: '>=0.9.0 <0.10.0'
logging: '>=0.9.0 <0.10.0'
dev_dependencies:
browser: any
logging_handlers: any
unittest: any
browser: '>=0.9.0 <0.10.0'
unittest: '>=0.9.0 <0.10.0'
1 change: 0 additions & 1 deletion test/all_tests.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
library all_tests;

import 'package:unittest/unittest.dart';
import 'package:unittest/html_enhanced_config.dart';

import 'src/simple_event_bus_test.dart' as simpleEventbus;
Expand Down

0 comments on commit ca03f63

Please sign in to comment.