These are chat archives for jdubray/sam

24th
Mar 2017
Jean-Jacques Dubray
@jdubray
Mar 24 2017 14:49
I am not trying to change the way you coded your framework, I am just trying to find a way to eliminate the step where you inject the actions into the views' event.
But maybe its not possible, it's to the use of hyperScript.
Jean-Jacques Dubray
@jdubray
Mar 24 2017 14:55

@DrecDroid This code runs on the client right? since it would execute the onclick handler

let element = h('a',
          {
            href,
            onclick : (e)=>{
              this.action(new actions.GoUrl(href))
              e.preventDefault()
              return false;
            }
          },
          h('img.post-thumbnail', { src : post.img_thumb })
        )

If that's the case, I truly believe that you could use something like the intent mechanism to generate your code on the server.

Rodrigo Carranza
@DrecDroid
Mar 24 2017 15:22
I truly don't understand the intent mechanism, how could I send the action to the system If I don't have a reference to the system, I've tried to reduce the coupling to only the action executor, the View can't know about the model or other things, It can only send actions. I'll will try to make an example soon.
Rodrigo Carranza
@DrecDroid
Mar 24 2017 16:11
mmm It's not as straightforward as I thought, apparently on server-side hyperscript doesn't produce HTMLElements with querySelector method, I'll need to polyfill that on the server, how fun is that :D
Jean-Jacques Dubray
@jdubray
Mar 24 2017 19:08
what is the HTML output of?
onclick : (e)=>{
              this.action(new actions.GoUrl(href))
              e.preventDefault()
              return false;
            }
What I was suggesting is to "fool" hyperscript on the server to generate some HTML that you can wire easily to the client to trigger the right action
If this conversation is not helpful, we don't need to have it, I just thought that it would be simpler to generate 100% of the HTML on the server, that's all I am trying to achieve. Other people might be interested in the result
Rodrigo Carranza
@DrecDroid
Mar 24 2017 19:35
It is not included in the outerHTML
Jean-Jacques Dubray
@jdubray
Mar 24 2017 19:36
I see, so it's probably not worth looking into it further.
Rodrigo Carranza
@DrecDroid
Mar 24 2017 19:38
Jean-Jacques Dubray
@jdubray
Mar 24 2017 19:40
well, if that works then the "intent" mechanism should work as well, that's all you need, but perhaps you prefer full functions.
Rodrigo Carranza
@DrecDroid
Mar 24 2017 19:40
I'm trying to bind https://www.npmjs.com/package/css-select with hyperscript to select using normal DOM selectors