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

Changes Support #24

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

Changes Support #24

wants to merge 4 commits into from

Conversation

Flamenco
Copy link
Contributor

@Flamenco Flamenco commented Feb 1, 2017

Request.js would not work in the browser, so we had to use XMLHttpRequest.

This is working very well in our production system.

@@ -124,6 +124,64 @@ couch.mango(dbName, mangoQuery, parameters).then(({data, headers, status}) => {
});
```

## Trigger A Design Update
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to another PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#26

// either request error occured
// ...or err.code=EDOCMISSING if document is missing
// ...or err.code=EUNKNOWN if statusCode is unexpected
});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit tricky API and it's more similar to publish-subscribe, than to promises which get fulfilled one time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use the promise to return the result of the subscribe request, and the callback for the actual subscription.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean exactly this. Promise represents the asynchronous operation which finishes either with some useful result (resolve) or fails with some error (reject). Publish/Subscribe (EventEmitter, Rx.Observable) represent continuous operations which can emit different events.

Is there any need for result of subscribe request? How should the callback code work if subscribe request fails?

Copy link
Contributor Author

@Flamenco Flamenco Feb 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The callback is not invoked at all if the promise fails. We could return an interface that has a subscribe method in the promise, but then we would have to cache any intermediate data.

I think you need both the promise and subscription. There is an async operation and a separate subscription.

I guess we could send an error to the subscription if the connection fails; Then you would not need to return a promise at all. But that would break chaining operations, and make the API less consistent.

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.

2 participants