Yomguithereal / react-blessed

A react renderer for blessed.
MIT License
4.46k stars 176 forks source link

Always include node in event callbacks #72

Open danielma opened 6 years ago

danielma commented 6 years ago

This is a big change, but I think it would make development a lot more pleasant.

Similar to working with React in a browser context, there are a lot of reasons that having a reference to a Node is useful.

One of the most basic React DOM cases is text inputs. You create the input, and use event.target.value to set the state of your component.

In react-blessed, having access to nodes in events would be useful, but they're largely not available (except focus and blur events).

Because of this, I end up needing to create refs for almost every element, which isn't necessarily bad, but my preference would be to just have access to the node in event callbacks.

Please let me know what you think of this change!

Yomguithereal commented 6 years ago

Hello @danielma. Thanks for your PR. I need to check the event emitting code again though. I don't remember what was chosen and how it worked. I guess we should give access to the blessed event data but I don't remember what blessed yield as event.

danielma commented 6 years ago

As far as I can tell from looking at blessed, this would give us full access to everything from blessed. Every blessed Node extends from EventEmitter, which recommends using this to get access to the emitter instance.

Yomguithereal commented 6 years ago

So there's no way in blessed to access current node in an event handler without needing to hit this? The payload never provides it?

danielma commented 6 years ago

@Yomguithereal yep, that's correct as far as I'm aware

geolessel commented 6 years ago

👍 I'd like to see this happen as well.

Yomguithereal commented 6 years ago

Can someone checks if blessed evolved regarding this matter? I did not track its most recent updates.

geolessel commented 6 years ago

@Yomguithereal blessed hasn't been updated in over 3 years.