Git Product home page Git Product logo

Comments (4)

cornerman avatar cornerman commented on June 1, 2024

In outwatch, we also handle class attributes differently, because we make them accumulate multiple assigned values. Currently, we just override the className member in RefectedAttrs (https://github.com/OutWatch/outwatch/blob/master/src/main/scala/outwatch/dom/DomTypes.scala#L110).

Style is maybe another "special kind" of attribute where a different handling might be needed. How do we decide, which of the values needs a special handling and which one does not? Why do you not like overriding the value?

from scala-dom-types.

raquo avatar raquo commented on June 1, 2024

Problem is, I want to be able to do pass both Observable[String] and Observable[Map[String, Boolean]] to the <-- method, but without allowing a custom type for cls in SDT that's not possible because with a String codec Laminar's ReactiveClassAttr expects the <-- method to accept Observable[String], whereas I need it to accept Observable[String | Map[String, Boolean]] as I can't create another <-- method that would accept Observable[Map[String, Boolean]] because of type erasure. (I hope that because-chain is not too confusing, lol)

I guess I could work around this in Laminar with e.g. implicit value classes, but I'm not a fan of using implicits for such a popular use case. Besides, it's merely coincidental that I want to retain a string-based API in this case, and if I didn't want that I wouldn't have been able to accomplish what I want at all.

I'm working on this now on Laminar side, we'll see how it goes...

from scala-dom-types.

cornerman avatar cornerman commented on June 1, 2024

I see, that is indeed a good use case! In your dsl, you cannot diverge from the type signature of SDT and you are forced to expose it. Only changing semantics is possible.

Totally agree with your initial approach of using an OpinionatedAttr trait then. At least, we can then circumvent the problem for some of the likely candidates.

from scala-dom-types.

raquo avatar raquo commented on June 1, 2024

Alright, coming soon as v0.9. Existing consuming libraries will just need to mix in two more traits (HTML and SVG) to retain current functionality.

from scala-dom-types.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.