Closed Rolandisimo closed 3 years ago
@Rolandisimo I think you need to pass new object itself as changing the same object will not work.
Maybe use Object.assign
or any other way to create new object it self instead of updating it's property
@Sidd27 not sure I understood your point. I am doing store.set()
and passing a new object {}
. Could you elaborate your point, please?
@Rolandisimo Ohhh Ok maybe I misunderstood your problem
It would be nice if you could isolate and reproduce this as a REPL since this should work and probably is an indication of a problem elsewhere in your code and not a bug.
An approximate version of your code can be found here: https://svelte.dev/repl/35a701791c434727a7516483e45a358f?version=3.31.0 where the reset
works fine. You could use that repl as starting point to add code until it breaks, but from what I can see this doesn't seem to be bug.
I would recommend joining the Discord Server where there are usually other users online willing to help with general questions and support.
@stephane-vanraes thanks for the repl. The immediate difference between your REPL and my implementation, is that I'm abstracting doing any changes to the state inside the store instead of doing it in the component. That seems the major difference and probably is what leads to the issue. Maybe I'm not understanding correctly how the store operates. Will try to adapt your REPL to my approach and see if I can reproduce the issue.
@stephane-vanraes I'm looking for a solution that abstracts checking the state of a word store.isWordSelected(key)
. Which means I need to access the store state inside the store. I found a way to make my approach work like this, but feels weird and makes the current state parameter in update
callback useless.
@stephane-vanraes I made the REPL with a similar approach to mine and broke it. I think this kind of issue could be solved by having a get
function exposed from a store. At the moment I don't quite get it what is the correct way of retrieving the current store state from within the store.
https://svelte.dev/repl/25d81cf3d88b4058b1544c429a4f1a13?version=3.31.0
One thing I don't want is to expose the data structure of the store. If this is not possible with the current implementation of svelte stores (which I hope it is), then this is a big drawback for those making complex store states.
Happy to be proven wrong. The documentation didn't help me understand how to make such abstractions. I thought of having a writable store and a readable store, but I was confused on how to make this work also.
We don't want to have a .get()
directly on store instances be part of the store contract, because then every custom store would have to implement it, and there would be more ways for .get()
and .subscribe()
to become out of sync. .get()
on stores doesn't provide you with anything that https://svelte.dev/docs#get doesn't.
Your REPL breaks because calling set({})
detaches the store value from the state
variable. Separately calling state = {}
is also bad because it gets the state
variable to a different empty object than the store value, and if one is mutated, the other will be unchanged.
GitHub issues aren't the right place for support questions like this. Please ask on StackOverflow or in our Discord chat room.
@Conduitry I hear you. I feel like this is an issue of documentation for more complex scenarios than setting a primitive value. I will ask for help in discord or stackoverflow (https://stackoverflow.com/questions/65382334/how-to-correctly-work-with-non-primitive-svelte-stores). Please answer my question then on stackoverflow since this thread is closed.
However, don't you think this is at least an issue of documentation not being clear enough and no info on troubleshooting?
GitHub issues aren't the right place for support questions like this. Please ask on StackOverflow or in our Discord chat room
I believe it is in cases where the documentation is unclear.
@Conduitry FYI your explanation feels vague and even a bit condescending to people not so familiar with the ins and outs of svelte.
@Rolandisimo we're trying to prevent github issues becoming yet another forum for endless discussion which would be better carried out in a realtime chat. Please understand and respect this.
If you think there needs to be clarity in documentation then by all means raise it as an issue and open a PR to help other users, especially if you find the answer given vague - this is again because this is not intended as a help forum, but more of a clear, concise tracker for issues with Svelte.
Finally please don't direct others to help you, Svelte and it's support, maintenance, contributions, and documentation are provided as a voluntary, free, opt-in service. There should be no expectation of anything, and people will assist members of the community where they see fit.
@antony I did go through a lengthy discussion on svelte Discord without any resolution. I understand the aim of not creating a forum in github issues, but say what you want, Discord is not a tracker for documenting issue resolution. There will be a new person coming in with the same questions as I did because there is no information on this in Svelte documentation. He will create the same issue, his issue will be closed and he will be redirected to the same discord and stackoverflow with no guarantee of getting to a solution.
Finally please don't direct others to help you,
If I would come to a car repair shop, tell them I have an issue and would get kicked out and asked to go ask fellow drivers what is the issue, I would never return to that repair shop ever again. As long as this frustration was not documented, this is exactly what happened.
raise it as an issue and open a PR to help other users
I would gladly do so if I would know the answer to my question or if I would know what is the problem with the documentation. I'm not so well versed in Svelte to know that yet. Since I didn't get an answer neither here, nor on Discord, nor on Stackoverflow, this again feels like people who know more telling less knowledgable devs to deal with their cases themselves.
I believe this is still an issue and it's the responsibility of the maintainers to help with the resolution of it. So far this is a poor experience with almost no help. You might think I feel entitled, however, it's not the case. You are providing a tool and you/the maintaines/creators (I believe) want other developers to use Svelte. Otherwise, there is no point in working on this project. Thus, not helping with the issue is counterproductive
This means that closing an issue just because "you don't want this to become a forum" even though this thread had only 7 messages before closing is weird, frankly.
cc @Rich-Harris
did go through a lengthy discussion on svelte Discord without any resolution. I understand the aim of not creating a forum in github issues, but say what you want, Discord is not a tracker for documenting issue resolution
Stackoverflow, as you mentioned, is an excellent forum for this. Discord is a way of getting help more directly, but comes with no guarantees.
If I would come to a car repair shop, tell them I have an issue and would get kicked out and asked to go ask fellow drivers what is the issue
Go to the car shop and ask them what they'll do for free. They might kick you out then.
I would gladly do so if I would know the answer to my question or if I would know what is the problem with the documentation
Raise an issue describing what is not clear about the documentation, and we will strive to clarify and make this clear. Right now it looks like your issue pertains to either: reassigning a variable to something else, which is a javascript/general programming problem and not something we'd document, or pertains to retrieving a store's own value from within the same store, which is a) a bad idea b) answered above. It needs to be made very clear, in a separate, isolated issue, where the documentation needs improvement, not tacked on to this issue, which is an non-valid bug report.
Since I didn't get an answer neither here, nor on Discord, nor on Stackoverflow
We provide no guarantees, especially of any sort of response time.
it's the responsibility of the maintainers to help with the resolution of it
no it isn't.
closing an issue just because "you don't want this to become a forum"
This issue was closed as resolved. If there is an issue with docs please raise another issue which details the specific issue around documentation
cc Rich-Harris
This is incredibly annoying. Please do not do that.
Describe the bug Calling
store.set({})
stops the store clients from seeing store updates and stops the DOM from updatingTo Reproduce Please check this PR for the setup that leads to the issue - https://github.com/Rolandisimo/bs-bingo/pull/1 You can clone the repository and run it on the
add-reset-button
Store is used in:
App.svelte
bingo.ts
Steps
Expected behavior The DOM keeps reacting to the store update
Actual behavior
Notes
$: console.log($selectedWordsStore);
If this turns out to be not a bug, then the documentation needs to be updated and much more complex custom store examples need to be added. Currently the only examples are of primitive store values like numbers and strings.