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

API #1

Open
jonathanong opened this issue Sep 2, 2014 · 12 comments
Open

API #1

jonathanong opened this issue Sep 2, 2014 · 12 comments

Comments

@jonathanong
Copy link
Member

right now it's push(res, [path], [options], [priority]) which has too much arity. i'm thinking about making it fluent, something like:

spdy(res).push(path)
  .priority(7)
  .send(new Buffer(1024))
  .acknowledge( err => )

an alternative is to be more koa like:

var push = spdy(res).push(path)
push.type = 'json'
push.body = new Buffer(1024)
push.acknowledge( err => )

which of the three approaches do you guys prefer? i think i'm leaning towards the fluent approach.

@dougwilson
Copy link

What is the acknowledge thing? an event? without the acknowledge (since I'm not clear on what it is), I would prefer:

spdy(res).push(path, body, {
  type: 'json',
  priority: 7
})

I'm not familiar enough to know which things are optional and which are not, though.

@jonathanong
Copy link
Member Author

haha i'm going to look it up right now. i think it's when the server acknowledges that the push stream is created.

@jonathanong
Copy link
Member Author

@jonathanong
Copy link
Member Author

it's also optional, so we would allow users to not even bother with acknowledge(). i also wanted to add a different, optional method of .finish() for when the entire stream is finished pushing.

@dougwilson
Copy link

if people don't always need to know if it was ack'd, it seems like it would be an event:

var resource = spdy(res).push(path, body, {
  type: 'json',
  priority: 7
})

resource.on('acknowledge', fn)
resource.on('finish', fn)

@jonathanong
Copy link
Member Author

yeah i'm trying to get away from event emitters. hahaha.

@jonathanong
Copy link
Member Author

i also want to return a promise so you can just do yield resource.acknowledge() or yield resource.finish()

@dougwilson
Copy link

gotcha :) i'm not saying i like ees, but i typically try to stay with the node.js core paradigms

@jonathanong
Copy link
Member Author

ya maybe i'll just add it anyways. won't know for sure what people want until i release something.

@rlidwka
Copy link

rlidwka commented Sep 2, 2014

Why do you like promises so much? I mean, all use-cases are covered with callbacks and generators. And promises seem to get in the way of chaining api too much.

In this case eventemitter+chaining api fits better imho.

@jonathanong
Copy link
Member Author

because then i could use generators on them and people who don't use generators can still use them. and they'll be compatible with await/async stuff

@jonathanong
Copy link
Member Author

okay i added basic stuff. need to add callback and event support next

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

No branches or pull requests

3 participants