These are chat archives for jdubray/sam

28th
Nov 2017
Rob Siera
@robsiera
Nov 28 2017 08:00
and line 277 is triggered even if view is empty. [typo corrections]
mpnsk
@mpnsk
Nov 28 2017 11:48
hi guys! Just quickly dropping by for a question
if the view is a function of the model doesn't that mean rewriting the entire view all the time and performance issues in a complex ui (non web stuff)?
*or function of the state, but the question still stands
Fred Daoud
@foxdonut
Nov 28 2017 12:59
@mpnsk if for example you use a virtual-DOM library, then that is a good fit since those libraries are made exactly for that purpose.
mpnsk
@mpnsk
Nov 28 2017 13:11
thanks! that makes sense :)
Jean-Jacques Dubray
@jdubray
Nov 28 2017 15:57
@robsiera it's definitely possible! I have seen it happening in other samples. I'll have to take a look.
@mpnsk if you give it a try without a virtual-dom library you'll see that works actually pretty well. I typically divide the UI into header/content/footer and I only generate the content part on average, the user experience is just fine. The only time I ran into trouble was for complex (JQuery) components like DataTables, or C3 charts,... in that case I have to partition the content a bit further (say master/detail) to avoid redrawing these components when I didn't need to.
Jean-Jacques Dubray
@jdubray
Nov 28 2017 16:03
Now, there are also a new kind of library that is currently being built that is more efficient than a virtual-dom library and offer a native API, based on Javascript Template Literals. For me that's the future of Web Application architectures. All the Web Frameworks, Virtual-Dom, ... will become obsolete, because what people want is to #UseThePlatform, not have to walk with the crutches of React, Angular or Vue. Virtual-Dom is inefficient enough that it will be disrupted.
I rewrote the clean-blog sample with one of these libraries: https://github.com/jdubray/startbootstrap-clean-blog-lit-html

As you can see the only difference between the two are:

  • a Template Literal tag in theme.js file ( html'...')
  • a specialized rendering component in index.html <state-representation> as a Web Component

Everything else is the same.
#UseThePlatform

Fred Daoud
@foxdonut
Nov 28 2017 16:07
Virtual-Dom is inefficient enough that it will be disrupted
@jdubray now I know performance tests are subjective etc. but petit-dom and domvm (both virtual-DOM libraries) are faster than lit-html
I understand your appreciation for lit-html
but virtual-DOM libraries still have their place in my opinion.
Jean-Jacques Dubray
@jdubray
Nov 28 2017 16:20
It's a question of API, why would you using something other than a native API even if the performance is the same.
All the tag-based libraries are interchangeable
Fred Daoud
@foxdonut
Nov 28 2017 16:21
I understand and I do not disagree; I was addressing your comment on virtual-DOM being inefficient.
Jean-Jacques Dubray
@jdubray
Nov 28 2017 16:23
I said it is was "inefficient enough" to be disrupted.
Fred Daoud
@foxdonut
Nov 28 2017 16:27
My apologies JJ if I misunderstood.
Jean-Jacques Dubray
@jdubray
Nov 28 2017 16:27
it's ok!
Fred Daoud
@foxdonut
Nov 28 2017 16:28
btw the onclick not firing in my lit-html attempt was my mistake (I knew it was, just couldn't figure it out)
because, being so used to JSX, I was writing onclick=${someHandlerFunction}
when it should be onclick="${someHandlerFunction}" (with quotes)
I don't really have a strong preference. I just want to be able to write templates that can use regular JavaScript code for behaviour (not framework/library-specific special attributes that make me have to learn how to write a conditional or loop every time) and that works well with view = function(model)
Jean-Jacques Dubray
@jdubray
Nov 28 2017 16:37
I ended up no using that aspect of the library. I am not sure why people think it's mandatory it.
V = S(M) takes care of it. The "State" function knows how to create a state representation with the correct intents/actions. Maybe I am missing something.
Fred Daoud
@foxdonut
Nov 28 2017 16:52
@jdubray as I said earlier, issue is that this requires global variables.
Paolo Furini
@pfurini
Nov 28 2017 16:54
@foxdonut :+1:
Jean-Jacques Dubray
@jdubray
Nov 28 2017 18:06
Sorry, I just have a single global variable to manage actions, I don't see the big deal about it. Considering that no action should be tied up to "components", regardless of how it will be implemented, that approach will require some kind of overall/global action namespace. The OOP view of the world is simply the wrong one, especially when it comes to Front-End architectures.
Fred Daoud
@foxdonut
Nov 28 2017 19:05
@jdubray I understand. I was referring to the code example that you had shown where every single action resulted in a separate global variable being created.
It's not as bad if you just have one global variable, but nevertheless personally I prefer an approach where modules of code do not rely on the presence of global variables.