UNPKG

@wordpress/widget-dashboard

Version:

Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.

1 lines • 1.6 kB
{"version":3,"file":"pending-actions-map.cjs","names":["observableMap"],"sources":["../../src/utils/pending-actions-map.ts"],"sourcesContent":["import { observableMap } from '@wordpress/compose';\nimport type { ObservableMap } from '@wordpress/compose';\n\n/**\n * The callback actions of each instance whose promise has not settled, by\n * uuid. Held by the dashboard, so the state outlives the surface that ran\n * the action.\n */\nexport type PendingActionsMap = ObservableMap< string, ReadonlySet< string > >;\n\nexport function createPendingActionsMap(): PendingActionsMap {\n\treturn observableMap();\n}\n\n/**\n * Marks one action of an instance pending or settled.\n *\n * @param {PendingActionsMap} map The dashboard's map.\n * @param {string} uuid The instance.\n * @param {string} actionId The action.\n * @param {boolean} pending Whether its promise is still settling.\n */\nexport function setActionPending(\n\tmap: PendingActionsMap,\n\tuuid: string,\n\tactionId: string,\n\tpending: boolean\n): void {\n\tconst next = new Set( map.get( uuid ) );\n\tif ( pending ) {\n\t\tnext.add( actionId );\n\t} else {\n\t\tnext.delete( actionId );\n\t}\n\n\tif ( next.size > 0 ) {\n\t\tmap.set( uuid, next );\n\t} else {\n\t\tmap.delete( uuid );\n\t}\n}\n"],"mappings":";;;;;;;AAUA,SAAgB,0BAA6C;CAC5D,QAAA,GAAOA,mBAAAA,cAAAA,CAAc;AACtB;;;;;;;;;AAUA,SAAgB,iBACf,KACA,MACA,UACA,SACO;CACP,MAAM,OAAO,IAAI,IAAK,IAAI,IAAK,IAAK,CAAE;CACtC,IAAK,SACJ,KAAK,IAAK,QAAS;MAEnB,KAAK,OAAQ,QAAS;CAGvB,IAAK,KAAK,OAAO,GAChB,IAAI,IAAK,MAAM,IAAK;MAEpB,IAAI,OAAQ,IAAK;AAEnB"}