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

Unified Diff: pkg/barback/lib/src/asset_forwarder.dart

Issue 261823008: Reorganize barback's source files. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: re-add barback/lib/src/internal_asset.dart Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/barback/lib/src/asset_cascade.dart ('k') | pkg/barback/lib/src/asset_id.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/asset_forwarder.dart
diff --git a/pkg/barback/lib/src/asset_forwarder.dart b/pkg/barback/lib/src/asset_forwarder.dart
deleted file mode 100644
index a2440e0114e6297e2c529f02357ccc9aa4655f6e..0000000000000000000000000000000000000000
--- a/pkg/barback/lib/src/asset_forwarder.dart
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library barback.asset_forwarder;
-
-import 'dart:async';
-
-import 'asset_node.dart';
-
-/// A wrapper for an [AssetNode] that forwards events to a new node.
-///
-/// A forwarder is used when a class wants to forward an [AssetNode] that it
-/// gets as an input, but also wants to have control over when that node is
-/// marked as removed. The forwarder can be closed, thus removing its output
-/// node, without the original node having been removed.
-class AssetForwarder {
- /// The subscription on the input node.
- StreamSubscription _subscription;
-
- /// The controller for the output node.
- final AssetNodeController _controller;
-
- /// The node to which events are forwarded.
- AssetNode get node => _controller.node;
-
- AssetForwarder(AssetNode node)
- : _controller = new AssetNodeController.from(node) {
- if (node.state.isRemoved) return;
-
- _subscription = node.onStateChange.listen((state) {
- if (state.isAvailable) {
- _controller.setAvailable(node.asset);
- } else if (state.isDirty) {
- _controller.setDirty();
- } else {
- assert(state.isRemoved);
- close();
- }
- });
- }
-
- /// Closes the forwarder and marks [node] as removed.
- void close() {
- if (_controller.node.state.isRemoved) return;
- _subscription.cancel();
- _controller.setRemoved();
- }
-}
« no previous file with comments | « pkg/barback/lib/src/asset_cascade.dart ('k') | pkg/barback/lib/src/asset_id.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698