Created
July 17, 2013 00:08
-
-
Save nikgraf/6016426 to your computer and use it in GitHub Desktop.
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
import 'dart:async'; | |
import 'package:polymer/polymer.dart'; | |
import 'package:observe/observe.dart'; | |
class CountdownClock extends CustomElement with ObservableMixin { | |
static final oneSecond = new Duration(seconds: 1); | |
@observable var timeLeft = new Duration(seconds: 72); | |
/* | |
* Initialize the timer who updates the duration periodically | |
* when the component has been added to the DOM. | |
*/ | |
void inserted() { | |
new Timer.periodic(oneSecond, _updateTimeLeft); | |
} | |
/* | |
* Update timeLeft until 0 seconds left. | |
*/ | |
void _updateTimeLeft(Timer _) { | |
if (timeLeft > new Duration(seconds: 0)) { | |
timeLeft = timeLeft - oneSecond; | |
} | |
} | |
} |
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
name: alarm | |
description: A sample WebUI application | |
dependencies: | |
browser: any | |
mdv: any | |
observe: any | |
polymer: any | |
shadow_dom: any |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment