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

defclass static methods and fields #492

Closed
brandonstubbs opened this issue Mar 26, 2024 · 5 comments
Closed

defclass static methods and fields #492

brandonstubbs opened this issue Mar 26, 2024 · 5 comments

Comments

@brandonstubbs
Copy link
Contributor

It would be great if defclass could support static methods and fields as it's widely available now.

At the moment as a workaround I am doing the following as mentioned here (https://clojureverse.org/t/modern-js-with-cljs-class-and-template-literals/7450/6):

(defclass DisplayVar
  (extends HTMLElement)
  (constructor [this]
    (super))

  Object
  (attributeChangedCallback [this name old-val new-val]
    (js/console.log name old-val new-val)))

(set! (.-observedAttributes DisplayVar) ["variable"])
@borkdude
Copy link
Member

Agreed

@borkdude
Copy link
Member

Is there any prior art of this in shadow-cljs? the defclass syntax stuff in squint is mostly borrowed ffrom shadow.

@brandonstubbs
Copy link
Contributor Author

brandonstubbs commented Mar 26, 2024

No, as he mentioned in that linked Clojureverse thread there weren't standards about it at the time. There is also issues in the Closure compiler for static and private class extensions. So this is probably the reason he never extended the functionality

This is actually one of the big reasons I am using squint. Using shadow with the Google Closure Compiler has issues with a lot of modern libraries that are starting to use these features and it doesn't look like they will be resolved soon.

@borkdude
Copy link
Member

borkdude commented Mar 26, 2024

Perhaps just:

Object
(^:static foobar []
    (js/fetch "https://clojure.org"))

would be ok-ish?

@brandonstubbs
Copy link
Contributor Author

Perhaps just:

Object
(^:static foobar []
    (js/fetch "https://clojure.org"))

would be ok-ish?

Yeah I think that would be ok

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

No branches or pull requests

2 participants