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

Feature request: give widgets access to other widget's commands/output? #267

Open
praxiq opened this issue Apr 5, 2017 · 2 comments
Open

Comments

@praxiq
Copy link

praxiq commented Apr 5, 2017

There are two use cases I'm considering:

  1. I want one widget to run two different commands with different refresh intervals. (Perhaps one is expensive and should be run less often.)

  2. I want two different widgets to use the output from the same command. (Again, perhaps the command is expensive and shouldn't be run twice to render both widgets.)

The easiest way to implement these would be to allow widgets to access the command output (or the rendered output) of other widgets. This way, you could have a widget which is not meant to display, whose sole purpose is to provide data for one or more other widgets. Presumably a widget would update, not just on its own refresh schedule, but every time any widget it refers to updates.

@hawkrives
Copy link
Contributor

When I've needed that, I made a widget with display:none that runs once every, say, 10 minutes.

This widget's command writes the output of the command to the disk, with eg. command: curl https://google.com > shared_file, and then the other two widgets can just read it: cat shared_file. The two "client" widgets (or however many) can run at a much more frequent interval, because they're less expensive; mine are visually simple, so I just have them run every ten seconds.


expensive.widget:

command: "curl https://google.com > output_file" # use stdout redirection to save to a file
refreshFrequency: '10m'
style: 'display: none'
render: ''

display_1.widget:

command: "cat output_file"
refreshFrequency: '10s'
# then actually render it

display_2.widget:

command: "cat output_file"
refreshFrequency: '10s'
# now render it differently

Hopefully that made some sort of sense and/or actually works?

@felixhageloh
Copy link
Owner

interesting 🤔
I also wonder if the data source/command runner could be abstracted out of the widget so that several widgets can listen to the same data source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants