Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I looked around the Windows skin source but I guess I'm too dumb for it because this line makes no sense to me https://github.com/FoxMoss/dote-dreamland-win95-example/blob...


I strongly suspect I know what that does because I worked with Svelte 4 for years (you no longer have to do this in Svelte 5. I can recommend Svelte 5, it's nice).

Basically, assigning a state to itself tells it to signal that that state has changed and update anything that is listening to it. The `state` object is actually a JS Proxy returned by createState [0], which allows intercepting the assignment to the `windows` property and emit signals. Usually you dont have to do that, but in this case, the proxy doesn't notice that `state.windows.push(X)` is a mutation. Only assignments directly to the state object count as mutations.

TLDR, `state.windows = state.windows` tells the framework that `windows` changed.

[0]: https://github.com/MercuryWorkshop/dreamlandjs/blob/1e7a34a1...


I was drafting a reply when you sent this, this is the correct interpretation and why I did it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: