Simplify example

This commit is contained in:
Kegan Dougal 2016-12-09 16:28:41 +00:00
parent b8025f5f6d
commit 47da1cbcf2
1 changed files with 4 additions and 8 deletions

View File

@ -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 {