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

docs: improve godoc on tick and every #320

Merged
merged 5 commits into from May 30, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions commands.go
Expand Up @@ -24,6 +24,12 @@ import (
// cmd := Every(time.Second, func(t time.Time) Msg {
// return TickMsg(t)
// })
//
// Notice that you'll need to keep calling Every after handling every
// TickMsg on update if you'd want to, for example, do something every X time.
// To clarify: Every will not loop and dispatch a message every given interval.
//
// Every is analogous to Tick in the Elm Architecture.
func Every(duration time.Duration, fn func(time.Time) Msg) Cmd {
return func() Msg {
n := time.Now()
Expand All @@ -45,6 +51,13 @@ func Every(duration time.Duration, fn func(time.Time) Msg) Cmd {
// cmd := Tick(time.Second, func(t time.Time) Msg {
// return TickMsg(t)
// })
//
// Notice that you'll need to keep calling Tick after handling every
// TickMsg on update if you'd want to, for example, do something every X time.
// To clarify: Tick will not loop and dispatch a message every given interval.
//
//
// Tick is analogous to Tick in the Elm Architecture.
func Tick(d time.Duration, fn func(time.Time) Msg) Cmd {
return func() Msg {
t := time.NewTimer(d)
Expand Down