Skip to content

Refactor getReadTheDocsConfig to use Promise#286

Merged
humitos merged 4 commits intohumitos/custom-eventfrom
humitos/custom-event-promise
Apr 15, 2024
Merged

Refactor getReadTheDocsConfig to use Promise#286
humitos merged 4 commits intohumitos/custom-eventfrom
humitos/custom-event-promise

Conversation

@humitos
Copy link
Copy Markdown
Member

@humitos humitos commented Apr 9, 2024

Follow Anthony's suggestion from
#64 (comment)

@humitos humitos changed the title Refactor getReadTheDocsConfig to use `Promise Refactor getReadTheDocsConfig to use Promise Apr 9, 2024
@humitos humitos marked this pull request as ready for review April 10, 2024 09:58
@humitos humitos requested a review from a team as a code owner April 10, 2024 09:58
@humitos humitos requested a review from agjohnson April 10, 2024 09:58
I found a pattern that I like 👍🏼 . I think it's a clear way to
communicate users what's going on, but also leaves the door open to
expand checks/validations in the future. I also imagine we could even
want to know "What projects are subscribing to the custom event?" in
case we need to contact them due to a breaking change or similar.

## Examples

#### Calling `event.detail.initialize()` without having defined the
`<meta ... />` HTML tag:


![Screenshot_2024-04-09_13-57-20](https://github.com/readthedocs/addons/assets/244656/b1757a08-aa44-4c3b-a5c2-8dbe73a477b4)

#### Calling `event.detail.data()` without calling `.initialize()`
first:


![Screenshot_2024-04-09_13-56-01](https://github.com/readthedocs/addons/assets/244656/476a934b-7668-4a58-8dbc-8e4254f6049c)


Closes #279
@humitos
Copy link
Copy Markdown
Member Author

humitos commented Apr 11, 2024

OK. I re-structured how we are calling the Promises and I think it's a lot easier to follow and understand now. Can you please do a final review here and let me know if this is fine? After that, I will merge this PR into the one's its based, and finish the small bits there in case there are any.

@humitos humitos requested a review from agjohnson April 11, 2024 14:55
Copy link
Copy Markdown
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

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

This looks good, the logic matches what I would expect 👍

return url;
}

function getReadTheDocsUserConfig(sendUrlParam) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Breaking this out is a good idea 👍 Often, splitting up nested async/promises makes the code easier to follow

@humitos humitos merged commit 98768a4 into humitos/custom-event Apr 15, 2024
@humitos humitos deleted the humitos/custom-event-promise branch April 15, 2024 08:58
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