-
-
Save leonardo5621/5f1a9c49d666bd9a7620696f10ee3747 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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