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

Side by Side Diff: ui/webui/resources/js/webui_listener_tracker.js

Issue 2935303003: Print Preview: Remove global onPrivetPrintFailed (Closed)
Patch Set: Fix Created 3 years, 6 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview Class that manages the addition and removal of WebUI
7 * listeners.
8 */
9
10 /**
11 * Create a WebUIListenerTracker to track a set of Web UI listeners.
12 * @constructor
13 */
14 function WebUIListenerTracker() {
dpapad 2017/06/15 00:19:18 The policy we've been following so far is to move
15 /**
16 * The Web UI listeners being tracked.
17 * @private {!Array<!WebUIListener>}
18 */
19 this.listeners_ = [];
20 }
21
22 WebUIListenerTracker.prototype = {
23 /**
24 * Adds a WebUI listener to the array of listeners being tracked, which
25 * will be removed when removeAll() is called.
26 * Do not use this method if the listener will be removed manually.
27 * @param {string} eventName The event to listen to.
28 * @param {!Function} callback The callback to run when the event is fired.
29 */
30 add: function(eventName, callback) {
31 this.listeners_.push(cr.addWebUIListener(eventName, callback));
32 },
33
34 /**
35 * Removes all Web UI listeners that are currently being tracked.
36 */
37 removeAll: function() {
38 while (this.listeners_.length > 0) {
39 cr.removeWebUIListener(this.listeners_.pop());
40 }
41 },
42 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698