Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 09 04:00
    notyy commented #222
  • Oct 09 03:59
    notyy closed #222
  • Oct 09 03:59
    notyy commented #222
  • Oct 08 20:28
    Atry commented #223
  • Oct 08 20:28

    Atry on master

    docs: fix typo Merge pull request #223 from Ja… (compare)

  • Oct 08 20:28
    Atry closed #223
  • Oct 08 20:20
    Jason-Cooke opened #223
  • Oct 07 03:30
    glmars commented #222
  • Oct 06 04:05
    notyy opened #222
  • Oct 04 11:29
    datalchemist commented #217
  • Oct 04 11:02
    datalchemist commented #217
  • Oct 04 06:58

    Atry on scalafmt

    (compare)

  • Oct 04 06:46

    Atry on master

    Run scalafmt Merge branch 'master' into scal… Merge pull request #221 from Th… (compare)

  • Oct 04 06:46
    Atry closed #221
  • Oct 04 06:46
    Atry synchronize #221
  • Oct 04 06:46

    Atry on scalafmt

    Update scalafmt to 2.0.1 Update sbt to 1.3.2 Merge pull request #215 from sc… and 2 more (compare)

  • Oct 04 06:06
    Atry commented #217
  • Oct 04 05:30
    glmars commented #217
  • Oct 04 05:09
    Atry closed #191
  • Oct 04 05:09

    Atry on master

    Update scalafmt to 2.0.1 Merge pull request #203 from sc… (compare)

杨博 (Yang Bo)
@Atry
I don't know.
Maybe
Justin Maat
@jxm262
yeah, i’m trying to figure out how to connect the views. Ok i’ll give it a shot and try to make a sample repo
Do you have any advice on how to implement a router for this? Say as an SPA application?
Similar to how react has react-router?
杨博 (Yang Bo)
@Atry
What I can tell is that Binding.scala is designed to work with mutable model and mutable mount point (e.g. DOM)
While the calculation between model and mount point shoul
should be pure
No need for a router library. Instead, simply matching the hash should work
Justin Maat
@jxm262
Ok sure, I’ll give this a try. I think it should work out nicely from what I can tell. I like this implementation more than react , at least that’s my initial thought
杨博 (Yang Bo)
@Atry
See the Binding.scala's todomvc example
Justin Maat
@jxm262
yes, but typically their is considerations like browser history, etc..
ok i see the section now your’re referring to.
thanks!
杨博 (Yang Bo)
@Atry
A very thin layer(no more than 20 loc) for HTML 5 URL rewritting maybe useful
Justin Maat
@jxm262
yeah, let me fully grok this project first :) I’m sure i’ll have more questions and possibly contributions.
this library seems very simple , unlike some of the others
杨博 (Yang Bo)
@Atry
Enjoy it!
Anthony Homan
@anthonyhoman
Hey everybody. I would appreciate any help on a problem I'm having. I threw together a quick reactive router app. It works fine if I hard-code the link targets. But if I try to pass in values from a States configuration object, I get a null reference error. What am I overlooking? Thanks
object ExampleApp extends js.JSApp {

  object Router {
    val stateMap: Map[String,State] = {
      Seq(States.homeState, States.nextState).foldLeft(Map[String,State]())((m,s) => m.updated(s.hash, s))
    }
    def getCurrentState: State = {
      stateMap.get(window.location.hash).getOrElse(States.homeState)
    }

    @dom def containerComponent = {
      <div>{ currentState.each.component.each }</div>
    }

    val currentState = Var(getCurrentState)
    @dom val hashBinding = window.location.hash = currentState.each.hash
    hashBinding.watch()
    window.onhashchange = { _: Any =>  currentState := getCurrentState }
  }

  final case class State(text: String, hash: String, component: Binding[Node])

  object States {
    val homeState: State = State("home", "#/", HomeComponent.content)
    val nextState: State = State("next", "#/next", NextComponent.content)
  }

  object HomeComponent {
    @dom def content = {
      <a href={ Constant(States.nextState.hash).each }>Next State</a>
    }
  }

  object NextComponent {
    @dom def content = {
      <a href={ Constant(States.homeState.hash).each }>Home State</a>
    }
  }

  def main() = dom.render(document.body, Router.containerComponent)
}
杨博 (Yang Bo)
@Atry
I guess you could make componet call-by-name, i.e component: => Binding[Node] instead of component: Binding[Node]
@anthonyhoman FYI
Anthony Homan
@anthonyhoman
That was it! Was pulling my hair out. Thank you. I ended up making component a function param so I could still use the State case class, and then it worked
Rahel Lüthy
@netzwerg

Hey there – I am evaluating Bindings.scala for a future project and I love it so far! However, I am struggling with IntelliJ's editor:

object D3Chart {

  @dom
  def chart: Binding[Div] = {

    val div: Div = <div id="d3"></div>

    val svg = d3.
      select(div).
      append("svg").
      attr("width", "100%").
      attr("height", 400)

    svg
      .append("text")
      .text("Hello from D3")
      .attr("y", 50)

    div
  }  // <-- Editor complains here

}

The message I get is:

Expression of type html.Div doesn't conform to expected Binding[html.Div]

If I wrap the final line in an artificial div, everything works fine:

<div>{div}</div>

I guess IntelliJ is struggling with the macro, right? Any tips? Here's the version I'am using:

IntelliJ IDEA 2016.1
Build #IU-145.970, built on April 18, 2016
JRE: 1.8.0_76-release-b162 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Tia!

Btw: The editor is showing a red mark, it compiles just fine...
杨博 (Yang Bo)
@Atry
You could try Scala IDE for Eclipse, it does not show red mark @netzwerg
Rahel Lüthy
@netzwerg
I'd rather not switch to a different IDE ;-) I was just hoping that someone else was maybe also using IntelliJ 2016.1 and could offer some help...
杨博 (Yang Bo)
@Atry
I found that IntelliJ is very slow for complicated Scala embedded XML literals, and its auto-formating for code is terrible for XML interpolation, too.
I guess you could vote this bug: https://youtrack.jetbrains.com/issue/SCL-9091
Rahel Lüthy
@netzwerg
Tx, I voted for the bug!
杨博 (Yang Bo)
@Atry
Scala IDE for Eclipse expands @dom macros when type checking. Unfortunately, IntelliJ IDEA does not. I also suggest Atom or other plain HTML editor for embedded XHTML templates.
Justin Maat
@jxm262
I’m totally stuck on this build file I’m making. I’m trying to integrate my client side app using Binding.scala into a shared Play app (2 main directories - client and server), but can’t seem to get the client to compile
any ideas on an example sbt build file?
so far I have -
import sbt.Project.projectToRef

addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)

lazy val jsProjects = Seq(client)

lazy val jvm = project.settings(
  scalaJSProjects := jsProjects,
  pipelineStages := Seq(scalaJSProd)).
  enablePlugins(PlayScala).
  aggregate(jsProjects.map(projectToRef): _*)

lazy val commonSettings = Seq(
  organization := "com.example",
  version := "0.1.0",
  scalaVersion := "2.11.7"
)

lazy val client = (project in file("client")).
  enablePlugins(ScalaJSPlugin).
  settings(commonSettings: _*).
  settings(
    jsDependencies += RuntimeDOM,
    persistLauncher in Compile := true,
    persistLauncher in Test := false,
    libraryDependencies ++= Seq(
      "com.thoughtworks.binding" %%% "dom" % "4.0.2",
      "com.lihaoyi" %%% "upickle" % "0.3.9",
      "org.singlespaced" %%% "scalajs-d3" % "0.3.3",
      "org.scala-js" %%% "scalajs-dom" % "0.9.0",
      "org.singlespaced" %%% "scalajs-d3" % "0.3.3",
      "com.lihaoyi" %%% "utest" % "0.4.3" % "test"
    )
  )
but running sbt compile gives this -
Main.scala:27: type MetaData is not a member of package xml
[error]     <div className="report">
[error]      ^
it’s like the build isn’t picking up the Binding.scala or something ??
杨博 (Yang Bo)
@Atry
I guess you need addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)
Justin Maat
@jxm262
I think I already have it at the top?
the first line in that build file i posted.
or did i place that in the wrong spot?
杨博 (Yang Bo)
@Atry
You need the compiler plugin whenever you have libraryDependencies += "com.thoughtworks.binding" %%% "dom" % "latest.release"
Justin Maat
@jxm262
right, but maybe i’m misunderstanding..
I have this
import sbt.Project.projectToRef

addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)

lazy val jsProjects = Seq(client)
...
杨博 (Yang Bo)
@Atry
They are different projects
You added the compiler plugin for the current project, maybe a Play project on JVM