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

Side by Side Diff: sky/sdk/example/raw/spinning_image.dart

Issue 1216303005: Convert image_cache to using Futures rather than callbacks (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: fix _loadComplete Created 5 years, 5 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
« no previous file with comments | « sky/sdk/example/game/lib/image_map.dart ('k') | sky/sdk/lib/mojo/asset_bundle.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:math' as math; 5 import 'dart:math' as math;
6 import 'dart:sky'; 6 import 'dart:sky';
7 7
8 import 'package:sky/mojo/net/image_cache.dart' as image_cache; 8 import 'package:sky/mojo/net/image_cache.dart' as image_cache;
9 9
10 double timeBase = null; 10 double timeBase = null;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 print("Existing image was loaded again"); 52 print("Existing image was loaded again");
53 } 53 }
54 } 54 }
55 55
56 bool handleEvent(Event event) { 56 bool handleEvent(Event event) {
57 if (event.type == "pointerdown") { 57 if (event.type == "pointerdown") {
58 return true; 58 return true;
59 } 59 }
60 60
61 if (event.type == "pointerup") { 61 if (event.type == "pointerup") {
62 image_cache.load(url2, handleImageLoad); 62 image_cache.load(url2).then(handleImageLoad);
63 return true; 63 return true;
64 } 64 }
65 65
66 return false; 66 return false;
67 } 67 }
68 68
69 void main() { 69 void main() {
70 image_cache.load(url1, handleImageLoad); 70 image_cache.load(url1).then(handleImageLoad);
71 image_cache.load(url1, handleImageLoad);
72 view.setEventCallback(handleEvent); 71 view.setEventCallback(handleEvent);
73 view.setBeginFrameCallback(beginFrame); 72 view.setBeginFrameCallback(beginFrame);
74 } 73 }
OLDNEW
« no previous file with comments | « sky/sdk/example/game/lib/image_map.dart ('k') | sky/sdk/lib/mojo/asset_bundle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698