Skip to content
This repository was archived by the owner on Aug 19, 2024. It is now read-only.

Subscription failure handling #3

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

penguinpowernz
Copy link

OK, made this thing handle subscription failures, even added a test for it 👍 (first time working with GoConvey).

Here's the skinny:

// standard go way
_, err := client.Subscribe("/foo", false, func(message wray.Message) {
  fmt.Println("-------------------------------------------")
  fmt.Println(message.Data)
})

if err != nil {
  fmt.Println("Subscription to /foo failed", err)
}

// USE THE PROMISE, LUKE!
promise, _ = client.Subscribe("/foo/*", false, func(message wray.Message) {
  fmt.Println("-------------------------------------------")
  fmt.Println(message.Data)
})

if !promise.Successful() {
  fmt.Println("Subscription to /foo/* failed", promise.Error())
}

I wasn't sure whether to skip the returning of the error as the second param, but it is a go idiom... so I thought I would leave it there. What say you @pythonandchips ?

@pythonandchips
Copy link
Owner

Hi @penguinpowernz thanks for the pull request!

I like the returning both the error and the promise nice work as we may have to other errors errors back.

I'll give it a quick test the night and merge it in.

Cheers Again

@irzhywau
Copy link

any chance to have this merged?

thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants