Skip to content

Instantly share code, notes, and snippets.

@leonardo5621
Last active July 21, 2022 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonardo5621/5f1a9c49d666bd9a7620696f10ee3747 to your computer and use it in GitHub Desktop.
Save leonardo5621/5f1a9c49d666bd9a7620696f10ee3747 to your computer and use it in GitHub Desktop.
func main() {
ctx, cancel := context.WithCancel(context.Background())
subscription := NewSubscription(ctx, NewFetcher("http.example.url.com"), 4)
time.AfterFunc(3*time.Second, func() {
cancel()
fmt.Println("Cancelling context:")
})
for item := range subscription.Updates() {
fmt.Println(item)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment