gizak / termui

Golang terminal dashboard
MIT License
13.14k stars 787 forks source link

/timer/ only for 1s? #123

Closed Chillance closed 7 years ago

Chillance commented 7 years ago

I thought when I saw: ui.Handle("/timer/1s", func(e ui.Event) {...}

you could modify to something like: ui.Handle("/timer/100ms", func(e ui.Event) {...} to get 100ms delays for it to be called, but doesn't seem to work. Am I missing something?

Thanks!

gizak commented 7 years ago

Hi @Chillance In this case you need to add a timer by ui.Merge("timer", ui.NewTimerCh(100*time. Millisecond)). This will add a 100ms timer into the underlying event system. The 1s timer just added by default for the sake of convenience.

Chillance commented 7 years ago

Wouldn't it be cool if it was possible to specify the timer that way I mentioned above? With your suggestion, it works, but this will set the same timeout for all timers, right?

gizak commented 7 years ago

That is actually a good idea! Parse the event string and add the timer accordingly, so that there is no need to add it by invoking ui.Merge.

And yes, if without explicitly using a different EvtStream, all events will share one DefaultEvtStream, then all events will be piped into it.

Chillance commented 7 years ago

Will you create a feature request for it here on github so I can track it?