Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: client/samples/swarm/SwarmApp.dart

Issue 9314024: Final CL to kill off client/samples . (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/samples/swarm/README ('k') | client/samples/swarm/SwarmState.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * A simple news reader in Dart.
7 */
8 class Swarm extends App {
9 /**
10 * Flag to insure the onLoad isn't called when callback from initializeFromUrl
11 * could occur before the document's onload event.
12 */
13 bool onLoadFired;
14
15 /** Collections of datafeeds to show per page. */
16 Sections sections;
17
18 /** The front page of the app. */
19 FrontView frontView;
20
21 /** Observable UI state. */
22 SwarmState state;
23
24 Swarm() : super(), onLoadFired = false {
25 Sections.initializeFromUrl((currSections) {
26 sections = currSections;
27 state = new SwarmState(sections);
28 setupApp();
29 });
30 // Catch user keypresses and decide whether to use them for the
31 // Streams app or pass them on to the browser.
32 document.on.keyUp.add((e) {
33 if (frontView != null) {
34 frontView.processKeyEvent(e);
35 }
36 });
37 }
38
39 /**
40 * Tells each data source to check the server for the latest data.
41 */
42 void refresh() {
43 sections.refresh();
44
45 // Hook up listeners about any data source additions or deletions. We don't
46 // differeniate additions or deletions just the fact that data feeds have
47 // changed. We might want more fidelity later.
48 sections.sectionTitles.forEach((title) {
49 Section section = sections.findSection(title);
50 // TODO(terry): addChangeListener needs to return an id so previous
51 // listener can be removed, otherwise anonymous functions
52 // can't easily be used. See b/5063673
53 section.feeds.addChangeListener((data) {
54 // TODO(jacobr): implement this.
55 print("Refresh sections not impl yet.");
56 });
57 });
58 }
59
60 /** The page load event handler. */
61 void onLoad() {
62 onLoadFired = true;
63 super.onLoad();
64 setupApp();
65 }
66
67 /**
68 * Setup the application's world.
69 */
70 void setupApp() {
71 // TODO(terry): Should be able to spinup the app w/o waiting for data.
72 // If the document is already loaded so we can setup the app anytime.
73 // Otherwise, we'll wait to setup the world until the document is ready
74 // to render.
75 if (onLoadFired && state != null) {
76 render();
77 // This call loads the initial data.
78 refresh();
79 eraseSplashScreen();
80 }
81 }
82
83 void render() {
84 frontView = new FrontView(this);
85 frontView.addToDocument(document.body);
86 }
87 }
OLDNEW
« no previous file with comments | « client/samples/swarm/README ('k') | client/samples/swarm/SwarmState.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698