Skip to content

What is the sanctioned way to extend Luxon's classes? #1017

Answered by icambron
cprecioso asked this question in Q&A
Discussion options

You must be logged in to vote

Yeah, Luxon's methods don't know about your subclasses, so without some sort of dependency injection system, those methods aren't going to be able to create instances of those subclasses.

IMO, modifying the prototype is the way to go. The risk is that one day Luxon adds a method with the same name and your code breaks, but that seems relatively unlikely, and if you are concerned about that, you could do some name prefixing.

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@icambron
Comment options

@cprecioso
Comment options

@baptiste00001
Comment options

@diesieben07
Comment options

@baptiste00001
Comment options

Answer selected by cprecioso
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants