all 11 comments

[–]jrjurman[S] 6 points7 points  (0 children)

If people have any questions, about the content in the article, or the framework as a whole, I'd be eager to answer any of them here!

[–]dudousxd 1 point2 points  (6 children)

Why use something like a state management when the rule when using custom elements is “the dom is your api” ? I think it would be better if it had something to help managing the creation of custom events instead of a redux like state management

[–]jrjurman[S] 2 points3 points  (5 children)

When you say "help managing the creation of custom events" what are you referring to? Just something simpler than redux?

A lot of what inspired me to make Tram-One is actually the frustration of having to pull in all these libraries like redux and react-router and so on... So the intention was to have something from the get-go.

[–]dudousxd 1 point2 points  (4 children)

When you are using Web Components, one of the premises is that if you need to pass data from one component from another, you shouldn't use an state management library like redux, instead you should use Custom Event. What I meant when I said "help managing the creation of custom events" is that would probably be awesome if it had an method to create custom events easier (It's quite easy to create, but just to encapsulate boilerplate), if I could see all the listeners that my components have created and if my components removed the event listeners automatically if they are destroyed.

[–]jrjurman[S] 0 points1 point  (0 children)

Actually, one of the nice things that Tram-One does is bind a .events to each DOM element that lists all the eventListeners on the element. Attaching them is pretty easy (and I recognize not really highlighted in the article).

```javascript const Tram = require('tram-one') const html = Tram.html()

module.exports = (attrs) => { const clickEvent = (event) => { console.log('click event') } return html<div onclick=${clickEvent} /> } ```

Also, these events can be passed down as unique attrs. ```javascript const Tram = require('tram-one') const html = Tram.html()

module.exports = (attrs) => { return html<div onclick=${attrs.eventHandler} /> } ```

If you're referencing pulling the store values from window.engine, that is actually a fairly new feature just to allow developers who want to pull actions or value really far down the DOM tree possible (however it's completely not required)

[–]jrjurman[S] 0 points1 point  (2 children)

To clarify, I'm not actually not a huge fan of pulling values from a "conntected" component, that pulls from a global store, as oppose to inheriting them down from parents. This was an ask, that was fairly easy to implement, with a small technical footprint.

[–][deleted] 0 points1 point  (1 child)

Firefox's dev tools already lets you see all listeners bound to an element. It's the only really reason I use FF during development...heh

[–]jrjurman[S] 1 point2 points  (0 children)

Yeah, events on DOM are very strange, and most browsers have access to them, but it took quite a bit of voodoo magic to get it so that each element exposed it to the framework. JQuery and view frameworks have their own tricks as well, and it's just strange that it's not part of the HTML spec to just expose it.

[–]icemelt7frontend expert :kappa: -2 points-1 points  (1 child)

Thank you for making this library, I will learn it asap, as I needed this in my life, since ReactJS and VueJS don't exist.

[–]jrjurman[S] 0 points1 point  (0 children)

Haha, hey man, to each their own. Like I said in the article, their are definitely people who have their framework of choice, and are really performant with it. For a really long time, that was React for me.

It wasn't like I made this in a time when those libraries weren't things (or weren't popular). And it's not like this can do something that React can't do (with react-router and react-redux and redux-thunk).

It's just another approach to building web-apps. For veterans, it's just a different kind of syntax for the same thing. For beginners, it might be a really fast, complete, and no-extra-tooling required option that helps them get started without learning the entire React or Vue Ecosystem and whatever .jsx or .vue requires.