mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 12:25:15 +08:00
💡 Document all Redux store files
This commit is contained in:
parent
fee9a016c6
commit
ef873dcda2
7 changed files with 69 additions and 0 deletions
|
@ -1,3 +1,12 @@
|
|||
/**
|
||||
* Action Types: Define unique identifiers for actions across all store modules.
|
||||
*
|
||||
* Keys are module-internal and can have any value.
|
||||
* Values must be unique across all store modules to avoid collisions.
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
|
||||
export default {
|
||||
// Transient data.
|
||||
SET_TRANSIENT: 'ONBOARDING:SET_TRANSIENT',
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* Action Creators: Define functions to create action objects.
|
||||
*
|
||||
* These functions update state or trigger side effects (e.g., async operations).
|
||||
* Exported functions must have unique names across all store modules.
|
||||
* Actions are categorized as Transient, Persistent, or Side effect.
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
|
||||
import ACTION_TYPES from './action-types';
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
/**
|
||||
* Controls: Implement side effects, typically asynchronous operations.
|
||||
*
|
||||
* Controls use ACTION_TYPES keys as identifiers to ensure uniqueness.
|
||||
* They are triggered by corresponding actions and handle external interactions.
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
|
||||
import { select } from '@wordpress/data';
|
||||
import { apiFetch } from '@wordpress/api-fetch';
|
||||
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* Hooks: Provide the main API for components to interact with the store.
|
||||
*
|
||||
* These encapsulate store interactions, offering a consistent interface.
|
||||
* Hooks simplify data access and manipulation for components.
|
||||
* Exported hooks must have unique names across all store modules.
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
|
||||
import { useSelect, useDispatch } from '@wordpress/data';
|
||||
|
||||
import { PRODUCT_TYPES, STORE_NAME } from '../constants';
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
/**
|
||||
* Reducer: Defines store structure and state updates for this module.
|
||||
*
|
||||
* Manages both transient (temporary) and persistent (saved) state.
|
||||
* Each module uses isolated memory objects to prevent conflicts.
|
||||
* The initial state must define all properties, as dynamic additions are not supported.
|
||||
* Reducers are separated per module to avoid conflicts in state management.
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
|
||||
import { createReducer, createSetters } from '../utils';
|
||||
import ACTION_TYPES from './action-types';
|
||||
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* Resolvers: Handle asynchronous data fetching for the store.
|
||||
*
|
||||
* These functions update store state with data from external sources.
|
||||
* Each resolver corresponds to a specific selector but must have a unique name.
|
||||
* Resolvers are called automatically when selectors request unavailable data.
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
|
||||
import { dispatch } from '@wordpress/data';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { apiFetch } from '@wordpress/data-controls';
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
/**
|
||||
* Selectors: Extract specific pieces of state from the store.
|
||||
*
|
||||
* These functions provide a consistent interface for accessing store data.
|
||||
* They allow components to retrieve data without knowing the store structure.
|
||||
* Exported functions must have unique names across all store modules.
|
||||
*
|
||||
* @file
|
||||
*/
|
||||
|
||||
import { STORE_KEY } from './constants';
|
||||
|
||||
const EMPTY_OBJ = Object.freeze( {} );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue