Skip to content

A different direction for callbacks and return values - #1

Open
sgentle wants to merge 2 commits into
ewenig:masterfrom
sgentle:master
Open

sgentle wants to merge 2 commits into
ewenig:masterfrom
sgentle:master

Conversation

@sgentle

@sgentle sgentle commented Oct 30, 2011

Copy link
Copy Markdown

Hi there,

I've been using mpdsocket to power the backend for a restful API I'm writing on top of mpd. I made a couple changes in my branch that I thought you might find relevant.

  1. Everything behaves a little strangely if there is data split over multiple packets, so I made that data accumulate better
  2. I altered the callback behaviour to be (err, response) instead of just (response), this is in line with nodejs's callback error handling but, more importantly, removes the need to have special _whatnot values.
  3. I removed _ordered_list and made it just return an array.
  4. I added support for non key-value string return values, in case mpd adds any.

All in all, return values now look like:

"I am a string"

{"key": "value", "key2": "value2"}

[{"key": "value"}, {"key": "value"}]

["I am a string", "I am another string"]

Not sure if that's useful to you, but it made my code a lot cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant