Problem Statement
Hello,
I was reading the documentation on Use Appsmith store and I noticed that the code example provided does not represent a good practice, since a getter (fetch_name) is simultaneously acting as a setter.
The Issue: The function is intended to retrieve data, but it explicitly calls storeValue('name', 'sam', true). This means the function mutates the store every time it is called to read it.
Current Example in Docs:
export default {
fetch_name () {
storeValue('name', 'sam', true); // 👈🏼 This sets the value instead of just fetching it
return appsmith.store.name;
},
update_name () {
storeValue('name', 'ben', true);
return appsmith.store.name;
},
}
Use Cases / User query reference
Proposed Changes:
I suggest updating the example to clearly separate the concerns (Get vs. Set)
export default {
// Pure getter
fetch_name () {
return appsmith.store.name;
},
// Setter
update_name () {
storeValue('name', 'ben', true);
return appsmith.store.name;
},
}
This change would make the distinction between reading from the store and writing to the store much clearer for new users.
BR
Audio/Video Recording
No response
Product Requirements Document
No response
Other Relevant Links
No response
Checklist
Problem Statement
Hello,
I was reading the documentation on Use Appsmith store and I noticed that the code example provided does not represent a good practice, since a getter (fetch_name) is simultaneously acting as a setter.
The Issue: The function is intended to retrieve data, but it explicitly calls storeValue('name', 'sam', true). This means the function mutates the store every time it is called to read it.
Current Example in Docs:
Use Cases / User query reference
Proposed Changes:
I suggest updating the example to clearly separate the concerns (Get vs. Set)
This change would make the distinction between reading from the store and writing to the store much clearer for new users.
BR
Audio/Video Recording
No response
Product Requirements Document
No response
Other Relevant Links
No response
Checklist