Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ func ExampleAt() {
}

func ExampleEvery() {
task := schedule.Every(time.Second, func() {
task := schedule.Every(time.Second, func() bool {
fmt.Println("1 second is over!")
return true // return false to stop the task
})

fmt.Println("Some stuff happening...")
Expand Down
4 changes: 2 additions & 2 deletions schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ func At(t time.Time, task func()) *Task {
return scheduler
}

// Every executes the task in the given interval.
// Every executes the task in the given interval, as long as the task function returns true.
// The function is non-blocking. If you want to wait for the task to be executed, use the Task.Wait method.
func Every(interval time.Duration, task func()) *Task {
func Every(interval time.Duration, task func() bool) *Task {
scheduler := newTask()
scheduler.nextExecution = time.Now().Add(interval)

Expand Down