PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / form-builder / blocks / src / lib / existingFieldsSnapshot.js

existingFieldsSnapshot.js in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 4.0.3, at form-builder/blocks/src/lib/existingFieldsSnapshot.js

22 lines 857 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Live snapshot of global `wppb_manage_fields` for Existing Fields + Conditional Logic.
3 * Seeded from the bridge; refreshed by post-save GET and per-edit PUT sync.
4 */
5 import { useSyncExternalStore } from '@wordpress/element';
6
7 import { createPubsubStore } from './createPubsubStore';
8
9 const store = createPubsubStore(
10 ( window.wppbFb && window.wppbFb.existingFields && window.wppbFb.existingFields.fields ) || [],
11 );
12
13 /** Replace the snapshot (post-save refetch, per-edit PUT reconcile, delete). */
14 export const setExistingFieldsSnapshot = ( next ) => store.set( next );
15
16 /** Read imperatively (store-mutating callbacks outside React). */
17 export const getExistingFieldsSnapshot = () => store.get();
18
19 /** Read reactively (React components). */
20 export const useExistingFieldsSnapshot = () =>
21 useSyncExternalStore( store.subscribe, store.get );
22