From 47da1cbcf2e5228b309f8f323e54485468d86701 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 9 Dec 2016 16:28:41 +0000 Subject: [PATCH] Simplify example --- example_test.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/example_test.go b/example_test.go index 1f463fe..3655b9b 100644 --- a/example_test.go +++ b/example_test.go @@ -4,23 +4,19 @@ import ( "fmt" ) -func Example_blockingSync() { +func Example_sync() { cli, _ := NewClient("https://matrix.org", "@example:matrix.org", "MDAefhiuwehfuiwe") syncer := cli.Syncer.(*DefaultSyncer) syncer.OnEventType("m.room.message", func(ev *Event) { fmt.Println("Message: ", ev) }) + + // Blocking version if err := cli.Sync(); err != nil { fmt.Println("Sync() returned ", err) } -} -func Example_nonBlockingSync() { - cli, _ := NewClient("https://matrix.org", "@example:matrix.org", "MDAefhiuwehfuiwe") - syncer := cli.Syncer.(*DefaultSyncer) - syncer.OnEventType("m.room.message", func(ev *Event) { - fmt.Println("Message: ", ev) - }) + // Non-blocking version go func() { for { if err := cli.Sync(); err != nil {