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

Usage of Button? #10

Closed
zenon opened this issue Jun 3, 2020 · 3 comments
Closed

Usage of Button? #10

zenon opened this issue Jun 3, 2020 · 3 comments

Comments

@zenon
Copy link

zenon commented Jun 3, 2020

Hi,

can you please tell me how to use the Button? It always seems to have the value given as argument "label" to the constructor.

Thank you!, z.

@fonsp
Copy link
Member

fonsp commented Jun 3, 2020

That's right - it does not make a lot of sense in most cases!

However, sometimes it can be useful to "trigger reactivity", for example:

@bind go Button("Go!")
data = let
    go # we reference `go`, making this cell a dependency of the first cell
    rand(100)
end
sum(data)

When you click Go!, the other two cells start running. So it's useful when you have code that does something different every time (this example), or code that creates side effects, like writing to a file or appending to an array.

@fonsp
Copy link
Member

fonsp commented Jun 3, 2020

You can use a CheckBox if you want to know the toggled state.

@zenon
Copy link
Author

zenon commented Jun 3, 2020

Nice trick. Thank you!

@fonsp fonsp closed this as completed Jun 3, 2020
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