@samitouri / QOS-React-2 / commits / fac24d462f
Fork 0

The library for web and native user interfaces.

React: Add @typechecks to `CallbackRegistry`

CommitSyncScript committed Jun 5, 2013 at 14:47 UTC fac24d462f1c7b654278cd1af5087b3b34d55ce8
1 file changed +22 -14
src/event/CallbackRegistry.js
+22 -14
@@ -14,6 +14,7 @@
14 * limitations under the License.
15 *
16 * @providesModule CallbackRegistry
17 + * @typechecks
18 */
19
20 "use strict";
@@ -22,18 +23,21 @@ var listenerBank = {};
23
24 /**
25 * Stores "listeners" by `registrationName`/`id`. There should be at most one
25 - * "listener" per `registrationName/id` in the `listenerBank`.
26 - * Access listeners via `listenerBank[registrationName][id]`
26 + * "listener" per `registrationName`/`id` in the `listenerBank`.
27 *
28 - * @constructor CallbackRegistry
28 + * Access listeners via `listenerBank[registrationName][id]`.
29 + *
30 + * @class CallbackRegistry
31 + * @internal
32 */
33 var CallbackRegistry = {
34
35 /**
33 - * Stores `listener` at `listenerBank[registrationName][id]. Is idempotent.
34 - * @param {string} domID The id of the DOM node.
35 - * @param {string} registrationName The name of listener (`onClick` etc).
36 - * @param {Function} listener The callback to to store.
36 + * Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
37 + *
38 + * @param {string} id ID of the DOM node.
39 + * @param {string} registrationName Name of listener (e.g. `onClick`).
40 + * @param {?function} listener The callback to store.
41 */
42 putListener: function(id, registrationName, listener) {
43 var bankForRegistrationName =
@@ -42,9 +46,9 @@ var CallbackRegistry = {
46 },
47
48 /**
45 - * @param {string} id.
46 - * @param {string} registrationName Name of registration (`onClick` etc).
47 - * @return {Function?} The Listener
49 + * @param {string} id ID of the DOM node.
50 + * @param {string} registrationName Name of listener (e.g. `onClick`).
51 + * @return {?function} The stored callback.
52 */
53 getListener: function(id, registrationName) {
54 var bankForRegistrationName = listenerBank[registrationName];
@@ -52,9 +56,10 @@ var CallbackRegistry = {
56 },
57
58 /**
55 - * Deletes the listener from the registration bank.
56 - * @param {string} id
57 - * @param {string} registrationName (`onClick` etc).
59 + * Deletes a listener from the registration bank.
60 + *
61 + * @param {string} id ID of the DOM node.
62 + * @param {string} registrationName Name of listener (e.g. `onClick`).
63 */
64 deleteListener: function(id, registrationName) {
65 var bankForRegistrationName = listenerBank[registrationName];
@@ -63,10 +68,13 @@ var CallbackRegistry = {
68 }
69 },
70
66 - // This is needed for tests only. Do not use in real life
71 + /**
72 + * This is needed for tests only. Do not use!
73 + */
74 __purge: function() {
75 listenerBank = {};
76 }
77 +
78 };
79
80 module.exports = CallbackRegistry;