Path: blob/trunk/third_party/closure/goog/pubsub/topicid.js
2868 views
// Copyright 2014 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314goog.provide('goog.pubsub.TopicId');15161718/**19* A templated class that is used to register {@code goog.pubsub.PubSub}20* subscribers.21*22* Typical usage for a publisher:23* <code>24* /** @type {!goog.pubsub.TopicId<!zorg.State>}25* zorg.TopicId.STATE_CHANGE = new goog.pubsub.TopicId(26* goog.events.getUniqueId('state-change'));27*28* // Compiler enforces that these types are correct.29* pubSub.publish(zorg.TopicId.STATE_CHANGE, zorg.State.STARTED);30* </code>31*32* Typical usage for a subscriber:33* <code>34* // Compiler enforces the callback parameter type.35* pubSub.subscribe(zorg.TopicId.STATE_CHANGE, function(state) {36* if (state == zorg.State.STARTED) {37* // Handle STARTED state.38* }39* });40* </code>41*42* @param {string} topicId43* @template PAYLOAD44* @constructor45* @final46* @struct47*/48goog.pubsub.TopicId = function(topicId) {49/**50* @const51* @private52*/53this.topicId_ = topicId;54};555657/** @override */58goog.pubsub.TopicId.prototype.toString = function() {59return this.topicId_;60};616263