Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Marius B. Kotsbak
    @mkotsbak
    If you want to optimize the size of the generated js for each page it has to be done like that. Each page might not use all of the code, so that the closure compiler could skip some part of it
    If size does not matter, I would say rather point to the exact same .js file (which could be cached by the client between each page)
    And then read the url for the app to react properly according to the page
    Or if you make your own Application class not extending JSApp you could launch it manually with parameters given from the html file
    Matthew Pocock
    @drdozer
    OK, I've looked in a launcher.js-- so one solution would be to have a bunch of object ABC extends PageApplication entry points, each of which produces its own launcher_ABC.js files that I can then load?
    Marius B. Kotsbak
    @mkotsbak
    Well, launcher is so simple that you just can make it yourself? Put the content in a script tag in each web page
    Matthew Pocock
    @drdozer
    What genertes -launcher.js? Is that standard sjs magic?
    Marius B. Kotsbak
    @mkotsbak
    object ABC extends PageApplication probably would not work with more than one in each module, as there should be just one main class
    The sjs sbt plugin I think, or the compiler
    Matthew Pocock
    @drdozer
    ok thanks - I've found the relevant bit of the sjs documentation
    Marius B. Kotsbak
    @mkotsbak
    ok
    Matthew Pocock
    @drdozer
    I'm using the ACE editor a lot. To hook it into a page, you call ace.edit(elementId) to attach the editor code to the div with that ID.
    So would I have to subclass View and over-ride render(parent, offset) to run the relevant javascript?
    and this will only work if the view is part of the page, so only if when you render a child, the parent is already added to the page
    Matthew Pocock
    @drdozer
    what I really need is an onAddedToPagecallback
    Matthew Pocock
    @drdozer
    OK, I've found a work-around
      override def render(parent: Node,
                          offset: Node) = {
        super.render(parent, offset)
        js.Dynamic.global.window.setTimeout(registerAce _, 0)
      }
    Marius B. Kotsbak
    @mkotsbak
    But it has issues: mkotsbak/widok-scalajs-react-wrapper#1
    Matthew Pocock
    @drdozer
    mm
    Marius B. Kotsbak
    @mkotsbak
    The widgets really should get callbacks when they are added and removed from the dom
    Matthew Pocock
    @drdozer
    I don't think you even need to use much magic for this, right? You just need to propagate it up from the root node when that is added
    Marius B. Kotsbak
    @mkotsbak
    Well when it is added you probably know because it is then constructed
    But when it disappears it is just removed from the dom
    Matthew Pocock
    @drdozer
    I've found this useful:
      implicit class NodeMemoriser[N <: Node](val _n: N) extends AnyVal {
        def rememberAs(f: N => ()): N = {
          f(_n)
          _n
        }
      }
    lets you do things like:
    MyComplicatedWidget(...).rememberAs(widget = _)
    Lets you declare your structure in-place, but write key references to widges into vars so that you can then go back and wire them.
    Matthew Pocock
    @drdozer
    I was wondering if there is a widok quasiquote?
    I have paragraphs of text with keywords and other spans embedded in. It is really ugly to keep on breaking up large, multi-line strings, with closing trebble quotes and stripMargin, then a coma, then the span, then opening the quotes up again.
    Paragraph(
      view"""Some very long
          |bit of text with an ${General.Inline(embedded).css(emphasizeThis)} element,
          |and a ${calculated} value and a $widget inside it.""".stripMargin)
    Matthew Pocock
    @drdozer
    oh, that doesn't work well because stripMargin interacts poorly with interpolation :(
    Matthew Pocock
    @drdozer
    Added #117 with a working implementation
    Mark Kegel
    @littlenag
    are there any large-ish demo apps that have been written with widok?
    i'm thinking something more than say a basic todo list
    i ask because i'm evaluating widok as one of many paths forward for my current side project
    i currently have a front end that's written in plain JavaScript with AngularJS to handle the SPA aspects
    the back end is already Scala, and i would love to have Scala all the way through the app
    Matthew Pocock
    @drdozer
    Hi @littlenag
    I've not built anything horendusly complex with widok
    Mark Kegel
    @littlenag
    have you built anything publically hosted?
    that i could take a look at and learn from?
    Matthew Pocock
    @drdozer
    This is what we're working on at the moment - it's not been optimized in any way, so it is slow and big:
    if you go to one of the tutorials (e.g. http://shortbol.ico2s.org/tutorial.html#/yourFirstScript) there's a 'your turn' box near the bottom. It's implemented with a mix of ace.js and widok.
    Mark Kegel
    @littlenag
    heh, i actually use ace.js as well...
    looking through the code this feels very much like angularjs does
    Mark Kegel
    @littlenag
    @drdozer what is the debugging story like? this is one of the things that angular has really gotten right and i'm wondering what facilities widok offers
    Matthew Pocock
    @drdozer
    to be honest I've not yet hit anyting complicated enough that I couldn't debug it by eye or with a couple of print statements