Skip to content

Instantly share code, notes, and snippets.

@terrasea
Created December 14, 2013 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terrasea/7954850 to your computer and use it in GitHub Desktop.
Save terrasea/7954850 to your computer and use it in GitHub Desktop.
<polymer-element name="store-changes-load" attributes="count">
<template>
<style>
:host {
display: none;
}
</style>
</template>
<script type="application/dart" src="store_changes_load.dart"></script>
</polymer-element>
<link rel="import" href="store-changes-load.html">
<polymer-element name="store-changes">
<template>
<style>
div {
font-size: 24pt;
text-align: center;
margin-top: 140px;
}
button {
font-size: 24pt;
margin-bottom: 20px;
}
</style>
<div>
<span>(item count: {{count}})</span>
<store-changes-load count="{{count}}"></store-changes-load>
</div>
</template>
<script type="application/dart" src="store_changes.dart"></script>
</polymer-element>
import 'package:polymer/polymer.dart';
/**
* A Polymer click counter element.
*/
@CustomTag('store-changes')
class StoreChanges extends PolymerElement {
@observable int count = 0;
StoreChanges.created() : super.created() {
}
@override
enteredView() {
super.enteredView();
count.changes.listen((ChangeRecord change) {
print(change.toString());
});
}
}
import 'package:polymer/polymer.dart';
import 'dart:async';
/**
* A Polymer click counter element.
*/
@CustomTag('store-changes-load')
class StoreChangesLoad extends PolymerElement {
@published int count;
StoreChangesLoad.created() : super.created() {
}
@override
void enteredView() {
super.enteredView();
new Timer.periodic(
new Duration(milliseconds: 900),
(t){
count++;
print(count.toString());
}
);
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sample app</title>
<link rel="stylesheet" href="test.css">
<!-- import the click-counter -->
<link rel="import" href="packages/test/store-changes.html">
<script type="application/dart">export 'package:polymer/init.dart';</script>
<script src="packages/browser/dart.js"></script>
</head>
<body>
<h1>Test</h1>
<div id="sample_container_id">
<store-changes></store-changes>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment