Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscriptions RFC: Should we treat "events" as an abstract "event stream"? #281

Closed
robzhu opened this issue Mar 6, 2017 · 4 comments
Closed

Comments

@robzhu
Copy link
Contributor

robzhu commented Mar 6, 2017

Re-model the concept of "events" as an abstract "event stream".
@dschafer @leebyron @rmosolgo @taion @OlegIlyenko @stubailo

Continuing the conversation from: #267 (comment)

@stubailo
Copy link
Contributor

stubailo commented Mar 6, 2017

I think it might be nice to make the title a bit more generic - I think it might be better to structure it as a "callback" that can be fired in response to anything, including events.

@stubailo
Copy link
Contributor

stubailo commented Mar 6, 2017

In terms of a JavaScript API, it would basically be like:

(pending the resolution of #282 the arguments can be different)

function subscriptionSetup(rootFieldName, rootFieldArgs, callback) {
  // hook up to pubsub system
  const subscription = pubsub.subscribe('my_event_name');

  subscription.on('data', (data) => {
    callback({ data: formatData(data) });
  }

  subscription.on('error', (error) => {
    callback({ error });
  }
}

This could be located in the "subscriptions system", or perhaps next to the subscription field resolver.

@robzhu robzhu added the RFC label Mar 29, 2017
@tcr
Copy link

tcr commented Apr 28, 2017

Modeling subscription payloads as a form of iterator—or in the case of future ES features, an AsyncIterators—is another viable alternative to pubsub. I think this most closely fits the definition of "event stream" you describe?

Specifying that subscription, payload receipt, and (most likely) unsubscription operations are required allows a client to model data flow using either paradigm. If this meets the criteria @leebyron was exploring in #267, we should reword the specification to be generic enough to accommodate both the type of API @stubailo describes above as well as a generic push model (like SSE, asynchronous iteration, etc.).

@robzhu
Copy link
Contributor Author

robzhu commented May 2, 2017

The RFC text has been updated to describe a generic "event stream" as opposed to specific events: #304

@robzhu robzhu closed this as completed May 2, 2017
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

No branches or pull requests

3 participants