Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension storage #179

Merged
merged 1 commit into from
Jan 3, 2024
Merged

Extension storage #179

merged 1 commit into from
Jan 3, 2024

Conversation

GarboMuffin
Copy link
Member

@GarboMuffin GarboMuffin commented Dec 31, 2023

There are two kinds of storage:

  • per-project: runtime.extensionStorage[id], for global things
  • per-sprite: target.extensionStorage[id], for things that may vary for each sprite

(note that this is a different metaphor than what Scratch uses for variables, where global variables are stored on the stage which itself just a sprite)

both are saved in project.json (or sprite.json, when exporting a single sprite) and thus must be any JSON-serializable value

to clear the data, use the delete operator or set the data to null/undefined

you are intended to index into extensionStorage with your extension's id; if you don't then your data won't be saved (it removes unused extensions)

@GarboMuffin
Copy link
Member Author

currently there are no helper methods, it's just a raw object you can read and write to. that can change if you want (eg. getOrDefault())

@LilyMakesThings
Copy link

This is precisely what I'm after

@yuri-kiss
Copy link
Member

same

@GarboMuffin
Copy link
Member Author

nobody quite answered whether they want any helpers so i assume you dont

@GarboMuffin GarboMuffin merged commit dd848db into develop Jan 3, 2024
2 checks passed
@GarboMuffin GarboMuffin deleted the extension-storage branch January 3, 2024 05:19
@yuri-kiss
Copy link
Member

nobody quite answered whether they want any helpers so i assume you dont

poop, yeah we forgot

@LilyMakesThings
Copy link

i'm good without helpers so it ain't a big deal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants