WC_Interactivity_Initial_State
in package
Manages the initial state of the Interactivity API store in the server and its serialization so it can be restored in the browser upon hydration.
It's a private class, exposed by other functions, like wc_initial_state
.
Tags
Table of Contents
- $initial_state : array<string|int, mixed>
- Map of initial state by namespace.
- get_state() : array<string|int, mixed>
- Get state from a given namespace.
- merge_state() : void
- Merge data into the state with the given namespace.
- render() : mixed
- Render the initial state.
- reset() : mixed
- Reset the initial state.
Properties
$initial_state
Map of initial state by namespace.
private
static array<string|int, mixed>
$initial_state
= array()
Methods
get_state()
Get state from a given namespace.
public
static get_state(string $namespace) : array<string|int, mixed>
Parameters
- $namespace : string
-
Namespace.
Return values
array<string|int, mixed> — The requested state.merge_state()
Merge data into the state with the given namespace.
public
static merge_state(string $namespace, array<string|int, mixed> $data) : void
Parameters
- $namespace : string
-
Namespace.
- $data : array<string|int, mixed>
-
State to merge.
Return values
void —render()
Render the initial state.
public
static render() : mixed
Return values
mixed —reset()
Reset the initial state.
public
static reset() : mixed