Skip to content

Conversation

@ohcibi
Copy link

@ohcibi ohcibi commented Mar 18, 2020

The former example where not technically wrong but pretty misleading,
since they suggested Promise (the one that can be used in
new Promise) is the default export of the rsvp package when it isn't.
Ideally when using the default import it should be called RSVP rather
then Promise but in fact neither of the code example require to use
that default export at all so I removed using that in the examples
entirely.

The former example where not technically wrong but pretty misleading,
since they suggested `Promise` (the one that can be used in
`new Promise`) is the default export of the `rsvp` package when it isn't.
Ideally when using the default import it should be called `RSVP` rather
then `Promise` but in fact neither of the code example require to use
that default export at all so I removed using that in the examples
entirely.
@rwjblue rwjblue requested a review from stefanpenner March 29, 2020 15:59
@stefanpenner
Copy link
Contributor

If the imports aren't working, that sounds like a bug. That should be fixed.

@ohcibi
Copy link
Author

ohcibi commented Mar 30, 2020

@stefanpenner this is not a bug in rsvp but an error in the documentation.

This line: https://github.com/tildeio/rsvp.js/blob/master/lib/rsvp.js#L47
tells that the default export of rsvp is only for legacy compat, i.e. there will be no default export anymore eventually (the old RSVP which this default export resembles wasn't an alias for Promise either, wasn't it?).

@stefanpenner
Copy link
Contributor

I see, the goal is for the default export to be Promise but due to compat it is a complex object with many properties..

```javascript
import Promise, { resolve } from 'rsvp';
import { all, resolve } from 'rsvp';
Copy link
Contributor

@stefanpenner stefanpenner Apr 1, 2020

Choose a reason for hiding this comment

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

In our docs we should ensure import { X } from 'rsvp'; should be either Promise or utility methods unique to RSVP. The import { resolve, all , reject, race } from 'rsvp' are odd, and their is no reason for RSVP to encourage non-standard promise usage patterns.

Let's use all from Promise, as that will make it easier for people to move to native.

import { Promise } from 'rsvp';

Promise.all

Copy link
Author

Choose a reason for hiding this comment

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

@stefanpenner your example and my changes are only about all but in fact your logic applies for reject, resolve, race and such as well, doesn't it? My idea was to make the imports consistent by importing all the same way as the others were already imported in those examples but I see that it would make even more sense the other way around. In fact I haven't even seen something that RSVP exports which is unique to it but I will look into it once more. I guess in any case I should update the docs to be consistent for all native Promise functions, right?

```javascript
import Promise, { resolve, reject } from 'rsvp';
import { all, resolve, reject } from 'rsvp';
Copy link
Contributor

Choose a reason for hiding this comment

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

^

```javascript
import Promise from 'rsvp';
import { Promise, race } from 'rsvp';
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's instead document Promise.race to better spec parity

```javascript
import Promise from 'rsvp';
import { Promise, race } from 'rsvp';
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's instead document Promise.race to better spec parity

```javascript
import Promise from 'rsvp';
import { Promise, race } from 'rsvp';
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's instead document Promise.race to better spec parity

```javascript
import Promise from 'rsvp';
import { reject } from 'rsvp';
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's instead document Promise.reject to better spec parity

```javascript
import Promise from 'rsvp';
import { resolve } from 'rsvp';
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's instead document Promise.resolve to better spec parity

@locks locks self-assigned this Apr 10, 2020
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.

4 participants