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

Does devcards reload when data changes? #15

Closed
uday-rayala opened this issue Jul 26, 2014 · 2 comments
Closed

Does devcards reload when data changes? #15

uday-rayala opened this issue Jul 26, 2014 · 2 comments

Comments

@uday-rayala
Copy link

I see that om-root-card does not reload the card when data is changed.

For example, if I change text to "yep it is not", it does not automatically reload unless the page is reloaded

(defcard omcard-ex
(dc/om-root-card widget {:text "yep it is"} {} { :unmount-on-reload true }))

Is there any option I can pass to do this?

@bhauman
Copy link
Owner

bhauman commented Jul 28, 2014

In order for the Devcards to be "stateful" while allowing code chages, it has to allow you to set an initial state while not blowing away the state that has accumulated so far. And that is what you are setting in the second parameter, the initial state. So it follows that when you want to return to the initial state, that you reload the page. Does that make sense?

If you want to reset to an original state without reloading the page you need to do that explicitly. IE a "reset" link in your app or you can do this:

(def state-atom (atom {:text "yep it is"}))
(dc/om-root-card widget state-atom))

;; just uncomment this line (and save file) when you want to reset the state
#_(reset! state-atom {:test "this is a new initial state"})  

It is my current opinion that reloading the page is the most natural way to "start over".

Does that help?

Also you don't want to have the :unmount-on-reload option set to true for React.

@uday-rayala
Copy link
Author

Thanks for the clarification.

I understand your point about not resetting the state on unmount. But for my use case, I wouldnt mind if the state is reset on unmount. Actually, I expect that to happen always.

So may be I will try and write a new devcard to reload the state every time. I am hoping it is not very hard to write one.

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

No branches or pull requests

2 participants