Skip to content

Commit

Permalink
Fix example to use value() method instead of appendText() for the…
Browse files Browse the repository at this point in the history
… textfield
  • Loading branch information
marcojakob committed May 13, 2015
1 parent 447da02 commit a425126
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ final _log = new Logger('event_bus_example');
void main() {
// Init logging.
initLogging();

// Log all events.
eventBus.on().listen((event) => _log.finest('event fired: ${event.runtimeType}'));


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

// Init Event fields.
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((_) {
// -------------------------------------------------
// Fire Event A
Expand All @@ -50,18 +50,18 @@ initLogging() {
Logger.root.onRecord.listen((LogRecord r) {
print('${r.time}\t${r.loggerName}\t[${r.level.name}]:\t${r.message}');
});

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

class Listener {
Element element;

TextAreaElement output;

StreamSubscription<String> subscription;

Listener(this.element) {
output = element.querySelector('textarea');
// Init buttons.
Expand All @@ -71,7 +71,7 @@ class Listener {
element.querySelector('.resume').onClick.listen((_) => resume());
element.querySelector('.cancel').onClick.listen((_) => cancel());
}

void listenForEventA() {
if (subscription != null) {
appendOuput('Already listening for an event.');
Expand All @@ -87,7 +87,7 @@ class Listener {
appendOuput('---');
}
}

void listenForEventB() {
if (subscription != null) {
appendOuput('Already listening for an event.');
Expand All @@ -103,7 +103,7 @@ class Listener {
appendOuput('---');
}
}

void pause() {
if (subscription != null) {
subscription.pause();
Expand All @@ -112,7 +112,7 @@ class Listener {
appendOuput('No subscription, cannot pause!');
}
}

void resume() {
if (subscription != null) {
subscription.resume();
Expand All @@ -121,7 +121,7 @@ class Listener {
appendOuput('No subscription, cannot resume!');
}
}

void cancel() {
if (subscription != null) {
subscription.cancel();
Expand All @@ -131,9 +131,9 @@ class Listener {
appendOuput('No subscription, cannot cancel!');
}
}

void appendOuput(String text) {
output.appendText('$text\n');
output.value += '$text\n';
output.scrollTop = output.scrollHeight;
}
}

0 comments on commit a425126

Please sign in to comment.