lihaoyi / scala.rx

An experimental library for Functional Reactive Programming in Scala
984 stars 79 forks source link

Reference to recommended conversion implicits for scalajs #69

Open LogicalTime opened 8 years ago

LogicalTime commented 8 years ago

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:

Implementations:

Voltir commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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"