Skip to content

[Docs]: Misleading logic in "Use Appsmith store" example (fetch_name)Β #2972

@lmarello

Description

@lmarello

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

  • Reviewed existing documentation to ensure this request is not duplicated.
  • Attached relevant media or supporting materials like links to the PRD, feature recordings, Slack or Discord links, and any other relevant resources.

Metadata

Metadata

Labels

DocumentationImprovements or additions to documentationUser Education PodIssues related to user education

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions