actionTypes

  1. const randomString = () =>
  2. Math.random().toString(36).substring(7).split('').join('.')
  3. const ActionTypes = {
  4. INIT: `@@redux/INIT${/* #__PURE__ */ randomString()}`,
  5. REPLACE: `@@redux/REPLACE${/* #__PURE__ */ randomString()}`,
  6. PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
  7. }
  8. export default ActionTypes

symbol-observable

  1. // SymbolConstructor与Symbol并没有关系
  2. declare global {
  3. interface SymbolConstructor {
  4. readonly observable: symbol
  5. }
  6. }
  7. // 假设如果存在 判断是否支持Symbol语法 不支持就取 (() => '@@observable')() = '@@observable'
  8. // Symbol的唯一降级到约定@@observable作为唯一
  9. const $$observable = /* #__PURE__ */ (() =>
  10. (typeof Symbol === 'function' && Symbol.observable) || '@@observable')()
  11. export default $$observable