Discuss Scratch

paulallington
New to Scratch
12 posts

Is anyone able to explain the project state machine please?

I'm trying to understand how the project state machine works - I've read through here: https://github.com/LLK/scratch-gui

So when you click on the “Save now” button, it sets the state to MANUAL_UPDATING (I think), but nothing actually happens. So I can see that the state is changing, but at what point is a call made to the projectHost to save it? And do those calls exist already, or do they need to be added to the scratch-gui?

Thanks!
apple502j
Scratcher
1000+ posts

Is anyone able to explain the project state machine please?

When the state is MANUAL_UPDATING, getIsUpdating returns true. (https://github.com/LLK/scratch-gui/blob/develop/src/reducers/project-state.js#L87 ) getIsUpdating change are received by Project Saver HOC(High Order Components) - https://github.com/LLK/scratch-gui/blob/develop/src/lib/project-saver-hoc.jsx , because they have isUpdating props set to its value (L413). If it changes, componentDidUpdate will be fired, and since isUpdating changed, updateProjectToStorage is called there (L81). updateProjectToStorage(L155) calls storeProject as well as handle errors. storeProject(L219) saves all assets and call onUpdateProjectData(L247), which by default, is saveProjectToServer(L398).

TL;DR: 1) When state changes to MANUAL_UPDATING and HOC receives the state change. 2) Yes, it exists. (see above)

Last edited by apple502j (March 31, 2020 07:46:19)


署名は、ディスカッションフォーラムの機能である。署名は、その人のすべての投稿の下部に追加される。署名は、BBCodeで記述できる。 署名を追加/変更/削除したい場合は、ディスカッションフォーラムのホームの一番下に行き、「Change your signature」を押す。署名の大きさは150pxまでである。これには、改行、画像を含む。- Japanese Scratch-Wiki 「署名

Powered by DjangoBB