[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> data-controls.js (source)

   1  /******/ (function() { // webpackBootstrap
   2  /******/     "use strict";
   3  /******/     // The require scope
   4  /******/     var __webpack_require__ = {};
   5  /******/     
   6  /************************************************************************/
   7  /******/     /* webpack/runtime/compat get default export */
   8  /******/     !function() {
   9  /******/         // getDefaultExport function for compatibility with non-harmony modules
  10  /******/         __webpack_require__.n = function(module) {
  11  /******/             var getter = module && module.__esModule ?
  12  /******/                 function() { return module['default']; } :
  13  /******/                 function() { return module; };
  14  /******/             __webpack_require__.d(getter, { a: getter });
  15  /******/             return getter;
  16  /******/         };
  17  /******/     }();
  18  /******/     
  19  /******/     /* webpack/runtime/define property getters */
  20  /******/     !function() {
  21  /******/         // define getter functions for harmony exports
  22  /******/         __webpack_require__.d = function(exports, definition) {
  23  /******/             for(var key in definition) {
  24  /******/                 if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  25  /******/                     Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  26  /******/                 }
  27  /******/             }
  28  /******/         };
  29  /******/     }();
  30  /******/     
  31  /******/     /* webpack/runtime/hasOwnProperty shorthand */
  32  /******/     !function() {
  33  /******/         __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  34  /******/     }();
  35  /******/     
  36  /******/     /* webpack/runtime/make namespace object */
  37  /******/     !function() {
  38  /******/         // define __esModule on exports
  39  /******/         __webpack_require__.r = function(exports) {
  40  /******/             if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  41  /******/                 Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  42  /******/             }
  43  /******/             Object.defineProperty(exports, '__esModule', { value: true });
  44  /******/         };
  45  /******/     }();
  46  /******/     
  47  /************************************************************************/
  48  var __webpack_exports__ = {};
  49  // ESM COMPAT FLAG
  50  __webpack_require__.r(__webpack_exports__);
  51  
  52  // EXPORTS
  53  __webpack_require__.d(__webpack_exports__, {
  54    "__unstableAwaitPromise": function() { return /* binding */ __unstableAwaitPromise; },
  55    "apiFetch": function() { return /* binding */ apiFetch; },
  56    "controls": function() { return /* binding */ controls; },
  57    "dispatch": function() { return /* binding */ dispatch; },
  58    "select": function() { return /* binding */ build_module_select; },
  59    "syncSelect": function() { return /* binding */ syncSelect; }
  60  });
  61  
  62  ;// CONCATENATED MODULE: external ["wp","apiFetch"]
  63  var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
  64  var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
  65  ;// CONCATENATED MODULE: external ["wp","data"]
  66  var external_wp_data_namespaceObject = window["wp"]["data"];
  67  ;// CONCATENATED MODULE: external ["wp","deprecated"]
  68  var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  69  var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  70  ;// CONCATENATED MODULE: ./node_modules/@wordpress/data-controls/build-module/index.js
  71  /**
  72   * WordPress dependencies
  73   */
  74  
  75  
  76  
  77  /**
  78   * Dispatches a control action for triggering an api fetch call.
  79   *
  80   * @param {Object} request Arguments for the fetch request.
  81   *
  82   * @example
  83   * ```js
  84   * import { apiFetch } from '@wordpress/data-controls';
  85   *
  86   * // Action generator using apiFetch
  87   * export function* myAction() {
  88   *     const path = '/v2/my-api/items';
  89   *     const items = yield apiFetch( { path } );
  90   *     // do something with the items.
  91   * }
  92   * ```
  93   *
  94   * @return {Object} The control descriptor.
  95   */
  96  
  97  function apiFetch(request) {
  98    return {
  99      type: 'API_FETCH',
 100      request
 101    };
 102  }
 103  /**
 104   * Control for resolving a selector in a registered data store.
 105   * Alias for the `resolveSelect` built-in control in the `@wordpress/data` package.
 106   *
 107   * @param {Array} args Arguments passed without change to the `@wordpress/data` control.
 108   */
 109  
 110  function build_module_select() {
 111    external_wp_deprecated_default()('`select` control in `@wordpress/data-controls`', {
 112      since: '5.7',
 113      alternative: 'built-in `resolveSelect` control in `@wordpress/data`'
 114    });
 115    return external_wp_data_namespaceObject.controls.resolveSelect(...arguments);
 116  }
 117  /**
 118   * Control for calling a selector in a registered data store.
 119   * Alias for the `select` built-in control in the `@wordpress/data` package.
 120   *
 121   * @param {Array} args Arguments passed without change to the `@wordpress/data` control.
 122   */
 123  
 124  function syncSelect() {
 125    external_wp_deprecated_default()('`syncSelect` control in `@wordpress/data-controls`', {
 126      since: '5.7',
 127      alternative: 'built-in `select` control in `@wordpress/data`'
 128    });
 129    return external_wp_data_namespaceObject.controls.select(...arguments);
 130  }
 131  /**
 132   * Control for dispatching an action in a registered data store.
 133   * Alias for the `dispatch` control in the `@wordpress/data` package.
 134   *
 135   * @param {Array} args Arguments passed without change to the `@wordpress/data` control.
 136   */
 137  
 138  function dispatch() {
 139    external_wp_deprecated_default()('`dispatch` control in `@wordpress/data-controls`', {
 140      since: '5.7',
 141      alternative: 'built-in `dispatch` control in `@wordpress/data`'
 142    });
 143    return external_wp_data_namespaceObject.controls.dispatch(...arguments);
 144  }
 145  /**
 146   * Dispatches a control action for awaiting on a promise to be resolved.
 147   *
 148   * @param {Object} promise Promise to wait for.
 149   *
 150   * @example
 151   * ```js
 152   * import { __unstableAwaitPromise } from '@wordpress/data-controls';
 153   *
 154   * // Action generator using apiFetch
 155   * export function* myAction() {
 156   *     const promise = getItemsAsync();
 157   *     const items = yield __unstableAwaitPromise( promise );
 158   *     // do something with the items.
 159   * }
 160   * ```
 161   *
 162   * @return {Object} The control descriptor.
 163   */
 164  
 165  const __unstableAwaitPromise = function (promise) {
 166    return {
 167      type: 'AWAIT_PROMISE',
 168      promise
 169    };
 170  };
 171  /**
 172   * The default export is what you use to register the controls with your custom
 173   * store.
 174   *
 175   * @example
 176   * ```js
 177   * // WordPress dependencies
 178   * import { controls } from '@wordpress/data-controls';
 179   * import { registerStore } from '@wordpress/data';
 180   *
 181   * // Internal dependencies
 182   * import reducer from './reducer';
 183   * import * as selectors from './selectors';
 184   * import * as actions from './actions';
 185   * import * as resolvers from './resolvers';
 186   *
 187   * registerStore( 'my-custom-store', {
 188   * reducer,
 189   * controls,
 190   * actions,
 191   * selectors,
 192   * resolvers,
 193   * } );
 194   * ```
 195   * @return {Object} An object for registering the default controls with the
 196   * store.
 197   */
 198  
 199  const controls = {
 200    AWAIT_PROMISE: _ref => {
 201      let {
 202        promise
 203      } = _ref;
 204      return promise;
 205    },
 206  
 207    API_FETCH(_ref2) {
 208      let {
 209        request
 210      } = _ref2;
 211      return external_wp_apiFetch_default()(request);
 212    }
 213  
 214  };
 215  
 216  (window.wp = window.wp || {}).dataControls = __webpack_exports__;
 217  /******/ })()
 218  ;


Generated: Thu Apr 25 01:00:03 2024 Cross-referenced by PHPXref 0.7.1