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

Exposing _counter and having value as a param in add_periodic_callback #579

Closed
ahuang11 opened this issue Aug 8, 2019 · 3 comments
Closed
Labels
type: enhancement Minor feature or improvement to an existing feature

Comments

@ahuang11
Copy link
Contributor

ahuang11 commented Aug 8, 2019

I was thinking that it'd be useful to have _counter as a public method/to show in periodic.params()?

import panel as pn
pn.extension()

test = pn.widgets.Toggle(name='Test')

def toggle():
    test.value = not test.value

periodic = test.add_periodic_callback(toggle, 1000)
print(periodic._counter)

Also maybe periodic.value = True mapped to periodic.start() and periodic.value = False mapped to periodic.stop() so there's less boilerplate and can use a .link() / .jslink() directly with a toggle

def toggle_periodic_callback(event):
    if event.new is True:
        periodic_cb.start()
    else:
        periodic_cb.stop()

becomes
toggle.jslink(periodic, value='value')

@ahuang11 ahuang11 added the TRIAGE Default label for untriaged issues label Aug 8, 2019
@ahuang11 ahuang11 changed the title Exposing _counter in add_periodic_callback Exposing _counter and having value as a param in add_periodic_callback Aug 8, 2019
@philippjfr philippjfr added type: enhancement Minor feature or improvement to an existing feature and removed TRIAGE Default label for untriaged issues labels Dec 29, 2019
@philippjfr
Copy link
Member

toggle.jslink(periodic, value='value')

Note this cannot work since the value toggle would be server-side, .link would work though.

@philippjfr
Copy link
Member

This would be an API change and users could simply keep their own counter so I'm -1 and will close.

@philippjfr
Copy link
Member

Also the other part of this proposal was implemented. You can now set the running parameter on PeriodicCallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Minor feature or improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants