Created
January 27, 2014 03:06
-
-
Save lucperkins/8642707 to your computer and use it in GitHub Desktop.
Making data types iterable in Dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@CustomTag('x-note-element') | |
class NoteElement extends LIElement with Polymer, Observable { | |
@published Note note; | |
NoteElement.created() : super.created(); | |
} | |
@CustomTag('x-notebook-element') | |
class NotebookElement extends PolymerElement { | |
@published Notebook notebook = new Notebook(new List<Note>()); | |
NotebookElement.created() : super.created(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<polymer-element name="x-note-element" extends="li"> | |
<template> | |
<h3>{{note.title}}</h3> | |
<p>{{note.content}}</p> | |
</template> | |
<script ...></script> | |
</polymer-element> | |
<polymer-element name="x-notebook-element"> | |
<template> | |
<ul> | |
<template repeat="{{note in notebook}}"> | |
<li is="x-note-element" note="{{note}}"></li> | |
</template> | |
</ul> | |
</template> | |
<script ...></script> | |
</polymer-element> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Note { | |
String title; | |
String content; | |
Note(this.title, this.content); | |
} | |
class Notebook extends Object with IterableMixin<Note> { | |
List<Note> notes; | |
Iterator get iterator => notes.iterator; | |
Notebook(this.notes); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment