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

Reference to recommended conversion implicits for scalajs #69

Open
LogicalTime opened this issue Jul 8, 2016 · 3 comments
Open

Reference to recommended conversion implicits for scalajs #69

LogicalTime opened this issue Jul 8, 2016 · 3 comments

Comments

@LogicalTime
Copy link

Not having standard safe implicits is a barrier to using scalarx with scalajs. Below are links to several implementations people have come up with. It would be nice to have some standard implicits that we could refer to and that the community could improve over time.

Observations:

  • The Hands on Scalajs book has a recommended implicit that needs to be updated asap.
  • Some people's implicits use .toTry and get values safely, some do not
  • Some people implicits wrap the rx value in a container node, making it easy to remove all child nodes. However adding these intermediate nodes doesn't work well when using libraries like bootstrap. (example Voltir/framework)
  • I am not sure how to combine safety, being sure to remove/replace all children, and not creating a container node that messes up bootstrap css/js.

Implementations:

@Voltir
Copy link
Collaborator

Voltir commented Jul 8, 2016

Yep. I remember having a similar conversation with a coworker. I think the wrapper was unnecessary in most cases, but there is some cases where it is necessary to wrap the rx in a real dom nodes (ie a rendered scalatag). The problem is using a def: Rx [HtmlTag] inside an unrendered var: Rx [HtmlTag] if no tag is rendered somewhere in the hierarchy the def ends up with a disconnected parent and the rx breaks. Our solution feels a bit heavy handed because we fixed it by just wrapping everything, but it does eliminate that really annoying corner case.

@LogicalTime
Copy link
Author

Do you think it would be possible without wrapping in a new node somehow. Adding a container node doesn't play well with bootstrap and I imagine other css.

e.g.

thead(
  span(cls:="_rx")(
    tr(th("txt1"), th("txt2"))
  )
)

@LogicalTime
Copy link
Author

Perhaps we need a way to use/extend the context ownership pattern? Send like we are running into a pattern similar to what is described in the readme.

"Ownership fixes leaks by keeping allowing a parent Rx to track its "owned" nested Rx. That is whenever an Rx recaculates, it first kills all of its owned dependencies, ensuring they do not leak. In this example, c is the owner of all the Rxs which are created in mkRx and kills them automatically every time c recalculates"

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