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

Playlist loader typescript #2144

Merged
merged 8 commits into from Feb 26, 2019
Merged

Playlist loader typescript #2144

merged 8 commits into from Feb 26, 2019

Conversation

itsjamie
Copy link
Collaborator

This PR will...

convert playlist loader to typescript.

Why is this Pull Request needed?

Progress towards typescripifying.

Are there any points in the code the reviewer needs to double check?

Loader interfaces similar enough to be used in: #2123

Resolves issues:

N/A

Checklist

  • changes have been done against master branch, and PR does not conflict

Copy link
Member

@michaelcunningham19 michaelcunningham19 left a comment

Choose a reason for hiding this comment

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

Nice 👍
A couple comments from reviewing the diff:

@@ -332,27 +331,29 @@ class PlaylistLoader extends EventHandler {
});
}

_handleTrackOrLevelPlaylist (response, stats, context, networkDetails) {
_handleTrackOrLevelPlaylist (response: LoaderResponse, stats: LoaderStats, context: PlaylistLoaderContext, networkDetails: any) {

Choose a reason for hiding this comment

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

Type for networkDetails ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So, networkDetails can be a XHR object, but since loaders can be passed in via config and return "whatever" as network details and this just pipes it around, we can't actually guarantee at the type level what it is. Or at least that was my reason for leaving it as "any".

I think that one option would be to put the networkDetails in the Context, that way the loader can define what networkDetails it uses.

This comment was marked as resolved.

// the level index to load
level: number | null
// TODO: what is id?
id: number | null

Choose a reason for hiding this comment

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

I'm assuming this can be null only initially or if something is invalid.
In which case could we normalize this to be -1? That way the type is always number  and we don't have to use the  as keyword

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure what the meaning of null was, but it could be valid to pick a better initalized value.

src/types/loader.ts Outdated Show resolved Hide resolved
src/types/loader.ts Outdated Show resolved Hide resolved
src/types/loader.ts Outdated Show resolved Hide resolved
src/types/loader.ts Outdated Show resolved Hide resolved
// the level index to load
level: number | null
// TODO: what is id?
id: number | null
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure what the meaning of null was, but it could be valid to pick a better initalized value.

@@ -332,27 +331,29 @@ class PlaylistLoader extends EventHandler {
});
}

_handleTrackOrLevelPlaylist (response, stats, context, networkDetails) {
_handleTrackOrLevelPlaylist (response: LoaderResponse, stats: LoaderStats, context: PlaylistLoaderContext, networkDetails: any) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So, networkDetails can be a XHR object, but since loaders can be passed in via config and return "whatever" as network details and this just pipes it around, we can't actually guarantee at the type level what it is. Or at least that was my reason for leaving it as "any".

I think that one option would be to put the networkDetails in the Context, that way the loader can define what networkDetails it uses.

Per feedback from John, the further defined response type caused issue in callers.
src/loader/playlist-loader.ts Outdated Show resolved Hide resolved
@@ -332,27 +331,29 @@ class PlaylistLoader extends EventHandler {
});
}

_handleTrackOrLevelPlaylist (response, stats, context, networkDetails) {
_handleTrackOrLevelPlaylist (response: LoaderResponse, stats: LoaderStats, context: PlaylistLoaderContext, networkDetails: any) {

This comment was marked as resolved.

src/loader/playlist-loader.ts Show resolved Hide resolved
src/loader/playlist-loader.ts Show resolved Hide resolved
Copy link
Member

@tjenkinson tjenkinson left a comment

Choose a reason for hiding this comment

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

🎉

Copy link
Member

@michaelcunningham19 michaelcunningham19 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@itsjamie itsjamie merged commit 7e0c599 into video-dev:master Feb 26, 2019
@itsjamie itsjamie deleted the playlist-loader-typescript branch February 26, 2019 01:57
@itsjamie itsjamie restored the playlist-loader-typescript branch March 15, 2019 16:36
@itsjamie itsjamie deleted the playlist-loader-typescript branch March 15, 2019 16:42
@johnBartos johnBartos added this to In progress in Typescript Integration via automation Aug 13, 2019
@johnBartos johnBartos added this to the 0.13.0 milestone Aug 13, 2019
@itsjamie itsjamie moved this from In progress to Reviewer approved in Typescript Integration Aug 28, 2019
@itsjamie itsjamie moved this from Reviewer approved to Done in Typescript Integration Aug 28, 2019
@robwalch robwalch added this to Done in 0.13.0 Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
0.13.0
  
Done
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants