|
@@ -40,20 +40,7 @@ MiddlewareRegistry.register(store => next => action => {
|
40
|
40
|
|
41
|
41
|
// The (externa API) event's name is the string representation of the
|
42
|
42
|
// (redux) action's type.
|
43
|
|
- let name = type.toString();
|
44
|
|
-
|
45
|
|
- // XXX We are using Symbol for (redux) action types at the time of this
|
46
|
|
- // writing so the Symbol's description should be used.
|
47
|
|
- if (name.startsWith('Symbol(') && name.endsWith(')')) {
|
48
|
|
- name = name.slice(7, -1);
|
49
|
|
- }
|
50
|
|
-
|
51
|
|
- // The polyfill es6-symbol that we use does not appear to comply with
|
52
|
|
- // the Symbol standard and, merely, adds @@ at the beginning of the
|
53
|
|
- // description.
|
54
|
|
- if (name.startsWith('@@')) {
|
55
|
|
- name = name.slice(2);
|
56
|
|
- }
|
|
43
|
+ const name = _getSymbolDescription(type);
|
57
|
44
|
|
58
|
45
|
_sendEvent(store, name, data);
|
59
|
46
|
break;
|
|
@@ -63,6 +50,29 @@ MiddlewareRegistry.register(store => next => action => {
|
63
|
50
|
return result;
|
64
|
51
|
});
|
65
|
52
|
|
|
53
|
+/**
|
|
54
|
+ * Gets the description of a specific <tt>Symbol</tt>.
|
|
55
|
+ *
|
|
56
|
+ * @param {Symbol} symbol - The <tt>Symbol</tt> to retrieve the description of.
|
|
57
|
+ * @private
|
|
58
|
+ * @returns {string} The description of <tt>symbol</tt>.
|
|
59
|
+ */
|
|
60
|
+function _getSymbolDescription(symbol: Symbol) {
|
|
61
|
+ let description = symbol.toString();
|
|
62
|
+
|
|
63
|
+ if (description.startsWith('Symbol(') && description.endsWith(')')) {
|
|
64
|
+ description = description.slice(7, -1);
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ // The polyfill es6-symbol that we use does not appear to comply with the
|
|
68
|
+ // Symbol standard and, merely, adds @@ at the beginning of the description.
|
|
69
|
+ if (description.startsWith('@@')) {
|
|
70
|
+ description = description.slice(2);
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ return description;
|
|
74
|
+}
|
|
75
|
+
|
66
|
76
|
/**
|
67
|
77
|
* Sends a specific event to the native counterpart of the External API. Native
|
68
|
78
|
* apps may listen to such events via the mechanisms provided by the (native)
|