Skip to content

Code provider facilitates self closing window - #38

Merged
langsamu merged 1 commit into
mainfrom
authorization-window-disposable
Sep 2, 2026
Merged

Code provider facilitates self closing window#38
langsamu merged 1 commit into
mainfrom
authorization-window-disposable

Conversation

@langsamu

@langsamu langsamu commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Follows up from #37. Specifically implements suggestion in #37 (comment).

Defined in provider interface. We want to return both

Used in code provider.

@langsamu
langsamu marked this pull request as ready for review August 26, 2026 10:57
}

[Symbol.dispose](): void {
this.cleanup()

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.

It is possible that for dispose to be invoked before the code flow has been completed - thereby requiring #cancel to be called here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it is possible for dispose to be called at any point. Giving the caller this responsibility is a risk to be alleviated by documentation.

Whether #cancel needs to be called or not, I don't know yet. I will need to iterate this.

}
}

class ValueWithCleanup implements Disposable {

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.

I was expecting AuthorizationCodeFlow to be the disposable class.

Specifically, I would expect the cleanup, cancel and Symbol.dispose methods to all belong to the same class.

What is the reason for this approach?

@langsamu langsamu Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

AuthorizationCodeFlow is an HTML element. Its life-cycle is bound to the DOM.
It is also an implementation of a CodeProvider, so it knows how to return something that is both disposable and carries a string value.

This implementation detail, ValueWithCleanup, is just a local container for the above (Disposable & { get value(): string }). It contains both the string value (code from Authorization Code flow) and the cleanup method (lambda that closes the authorization window.

@langsamu
langsamu merged commit cad9322 into main Sep 2, 2026
5 checks passed
@langsamu
langsamu deleted the authorization-window-disposable branch September 2, 2026 15:41
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