Budibase is an open-source low-code platform for creating internal apps in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s 🚀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
766 B

/**
* buildStateOrigins
*
* Builds an object that details all the bound state in the application, and what updates it.
*
* @param screenDefinition - the screen definition metadata.
* @returns {Object} an object with the client state values and how they are managed.
*/
export const buildStateOrigins = screenDefinition => {
const origins = {}
function traverse(propValue) {
for (let key in propValue) {
if (!Array.isArray(propValue[key])) continue
if (key === "_children") propValue[key].forEach(traverse)
for (let element of propValue[key]) {
if (element["##eventHandlerType"] === "Set State")
origins[element.parameters.path] = element
}
}
}
traverse(screenDefinition.props)
return origins
}