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

Should we have child.textMaybe <-- ... ? #96

Open
yurique opened this issue Dec 28, 2020 · 3 comments
Open

Should we have child.textMaybe <-- ... ? #96

yurique opened this issue Dec 28, 2020 · 3 comments
Labels
design ergonomics need to find time https://falseknees.com/297.html needs design The solution is not clear, or I am not very happy with it

Comments

@yurique
Copy link
Contributor

yurique commented Dec 28, 2020

or, maybe, child.text.maybe ?

@raquo
Copy link
Owner

raquo commented Dec 30, 2020

How would you guys feel about a single child <-- method that accepts (observable: Observable[A: Renderable])? where Renderable[A] is basically A => ChildNode?

I'm not a fan of conceptual complexity (implicits and stuff) but it might be worth it here. That would also work similarly outside of child <--, with an implicit def renderableToMod[V: Renderable](v: V): Mod[ReactiveElement.Base].

@yurique
Copy link
Contributor Author

yurique commented Dec 30, 2020

I like it.

Maybe this will also help scalac figure out stuff like this:

div(
  Option("a").getOrElse("b")
)

@raquo raquo changed the title Should we have child.textMaybe <-- ... ? [Laminar] Should we have child.textMaybe <-- ... ? Jan 2, 2021
@raquo raquo transferred this issue from raquo/Airstream May 2, 2021
@raquo raquo changed the title [Laminar] Should we have child.textMaybe <-- ... ? Should we have child.textMaybe <-- ... ? May 2, 2021
@raquo raquo added the design label May 2, 2021
@raquo
Copy link
Owner

raquo commented May 2, 2021

I'm now wondering if there's a good reason to keep child.text separate from child at all. Due to our implicits, we can already say child <-- fooObservable.map(_.toString) and that will work because an implicit conversion will be inserted into _.toString. But child <-- stringObservable will not work because there's no place to inject the implicit. Which feels unintuitive to someone not familiar with our implicits.

Our child.text already has def <--[T]($node: Source[T])(implicit ev: T => TextNode), we might as well just make child <-- itself into def <--[T]($node: Source[T])(implicit ev: T => Child), then we won't need child.text at all.

raquo added a commit that referenced this issue Nov 23, 2022
…le from #96.

* Resilience against externally removed child elements
* Support for moving child elements from one inserter to another
* onMountInsert gracefully handling the above
* Text nodes are now updated, not re-created
* New Renderable typeclass to expand text-to-node and child.text capabilities
* Laminar no longer clears the DOM of `{child,children,child.*} <-- stream` when the element is unmounted and re-mounted, it now retains the previously added elements in the DOM
raquo added a commit that referenced this issue Jan 4, 2023
…le from #96.

* Resilience against externally removed child elements
* Support for moving child elements from one inserter to another
* onMountInsert gracefully handling the above
* Text nodes are now updated, not re-created
* New Renderable typeclass to expand text-to-node and child.text capabilities
* Laminar no longer clears the DOM of `{child,children,child.*} <-- stream` when the element is unmounted and re-mounted, it now retains the previously added elements in the DOM
@raquo raquo added the need to find time https://falseknees.com/297.html label Jan 6, 2023
@raquo raquo added the needs design The solution is not clear, or I am not very happy with it label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design ergonomics need to find time https://falseknees.com/297.html needs design The solution is not clear, or I am not very happy with it
Projects
None yet
Development

No branches or pull requests

2 participants