Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mets.corals.io/wp-content/plugins/ultimate-blocks/src/stores/mainStore/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mets.corals.io/wp-content/plugins/ultimate-blocks/src/stores/mainStore/index.js
import { createReduxStore, register, dispatch } from '@wordpress/data';
import reducer from './reducer';
import selectors from './selectors';
import actions from './actions';
import deepmerge from 'deepmerge';
import ManagerBase from '$Base/ManagerBase';

/**
 * Main store for plugin.
 *
 * @param {string} storeName store name
 * @function Object() { [native code] }
 */
class MainStore extends ManagerBase {
	/**
	 * Name of the store.
	 * Will be used as an id to distinguish plugin store from other ones.
	 *
	 * @type {string|null}
	 */
	storeName = null;

	/**
	 * Register store.
	 *
	 * @param {Object} [extraState={}] extra state to use
	 */
	#registerStore = (extraState = {}) => {
		const innerExtraState = {
			storeName: this.storeName,
		};

		const reducerOptions = {
			reducer: reducer(deepmerge(innerExtraState, extraState)),
			selectors,
			actions: actions(this.storeName),
		};

		const generatedStore = createReduxStore(this.storeName, reducerOptions);

		register(generatedStore);
	};

	/**
	 * Initialization logic for pro store.
	 *
	 * @param {string} storeName store name
	 */
	_initLogic(storeName) {
		// store id for outside use to global context
		const context = self || global;
		context.ub_main_store_id = storeName;

		this.storeName = storeName;
		this.#registerStore();
	}

	/**
	 * Get main store id.
	 *
	 * @return {string} store id
	 */
	getStoreId() {
		const context = self || global;
		return this.storeName ?? context.ub_main_store_id;
	}

	/**
	 * Store action dispatch.
	 *
	 * @return {Object} object containing available store actions.
	 */
	dispatch = () => {
		return dispatch(this.getStoreId());
	};
}

/**
 * @module mainStoreObj
 */
export default new MainStore();

Spamworldpro Mini