Skip to content

Instantly share code, notes, and snippets.

@jjinux
Created November 27, 2012 19:46
Show Gist options
  • Save jjinux/4156541 to your computer and use it in GitHub Desktop.
Save jjinux/4156541 to your computer and use it in GitHub Desktop.
<html><body>
<element name="x-chat-window" constructor="ChatWindowComponent" extends="div">
<template>
<div>
<textarea rows="10" class="chat-window" disabled>
<template iterate="s in chatWindowText">
{{s}}
</template>
</textarea>
</div>
</template>
<script type="application/dart">
import 'package:web_components/web_components.dart';
class ChatWindowComponent extends WebComponent {
List<String> chatWindowText = new List<String>();
displayMessage(String from, String msg) {
_display("$from: $msg\n");
}
displayNotice(String notice) {
_display("[system]: $notice\n");
}
_display(String str) {
chatWindowText.add(str);
// You have to call dispatch whenever Web Component data changes
// and it's not the result of a user event. That happens a lot
// for this method.
dispatch();
}
}
</script>
</element>
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment