-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify _input/_change names #22
Comments
I think these field names are based on the DOM event names themselves: |
@spl If that's the case, it still seem strange because all those elements have both of those events. |
@mightybyte No argument there. I'm guessing these options were chosen for their immediate/common usefulness rather than trying to support all available event types, since they are not all equally useful. Of course, it would be nice to easily use any DOM event on any widget. I've run into this problem myself. |
Yeah. I'm playing with some different ideas for building widget infrastructure in the reflex-dom-contrib package. I'm currently just building on top of reflex-dom widgets, but I certainly don't have to. If you want to play with API ideas for supporting all DOM event types, I'll definitely accept those changes in that repo. To start with you should probably make a separate module to avoid breaking backwards compatibility, but eventually we can merge all these ideas together. |
@mightybyte I looked at it briefly, and it looks nice! I did borrow the useful As for the input widgets, I've found that it's important to be careful about the source and flow of events to avoid cycles. For example, use It would be nice if all widgets naturally didn't allow for event cycles. That is, I'd like the value of the input when it actually changes in the DOM, and whether that change be due to a programmatic update or a user input shouldn't matter, but my program shouldn't loop infinitely if I tie the widget's |
It is possible to automatically stop the loop using value equality - e.g. I also started working on this previously and I think we can avoid a lot of Btw. @mightybyte - does the cool switchable widget trick work over the new FWIW here was my attempt: On Wed, Sep 2, 2015 at 6:07 PM, Sean Leather notifications@github.com
|
@Saulzar I'm not sure how to stop the loop using Also, wrt the ideas about input widgets, I think it is useful to keep in mind that the DOM event types are not a closed world. New event types can be created and handled. I've seen some JQuery-based libraries that do this. From that perspective, it would be nice if one could easily register a Reflex-based event handler for an arbitrary DOM event. I did this, but it required a massive hack using a GHCJS JQuery wrapper to listen for the event and call a Reflex handler. (This was challenging because (1) |
Actually no - you're right. I think there's nothing you can do if you have You should be able to make a wrapper to register a listener for arbitrary I'm not really familiar with jquery at all, so I have no idea how that On Wed, Sep 2, 2015 at 9:25 PM, Sean Leather notifications@github.com
|
It does, and it didn't work. ;) |
Just to clarify, what I'm describing is not a JQuery-specific thing. You can trigger and listen to arbitrarily-named event types in plain old JavaScript. It's just that I observed it happening in JQuery libraries. |
Thinking it's probably something to do with the way the JS lib is loaded - As always - feel free to provide a small example which doesn't work :) On Wed, Sep 2, 2015 at 10:22 PM, Sean Leather notifications@github.com
|
@spl Yes, the _change events are a very important tool for eliminating event loops. There are ways to do it without them, but using them can make things quite a bit simpler. @Saulzar I haven't tried the switchable widget with fan, so I'm not sure. |
Hi everyone, This has been an interesting discussion to follow! A lot of valid concerns have been raised, and I hope to be able to address them soon. Regarding non-custom DOM events, I've begun putting in place a system that allows us to support all of them, without paying for the ones we don't use: https://github.com/ryantrinkle/reflex-dom/blob/master/src/Reflex/Dom/Widget/Basic.hs#L720 . This domEvent function allows you to say something like The remaining issue with supporting all built-in DOM events is that it is not quite clear to me what should be marshaled for each DOM event type, and whether we can do it lazily to avoid making users who don't care about the details of common events pay for marshaling a bunch of extra metadata. I'd very much welcome suggestions on this. Regarding cycles, I think that separation between change/input events and updated values will always be necessary to a degree - some logic does depend on whether the user made the change or the software made the change. (I completely agree, by the way, that having "change" and "input" be distinct is very confusing, but unfortunately it is the way the DOM works - the new uniform approach to events may actually make things worse in this regard, because "the wrong" event will now be available.) However, I would be very supportive of any concrete proposals that would decrease the chance of users running into cycles or improve debugging for ones that exist. Regarding custom DOM events, I have not looked into this, but I'd be happy to hear suggestions on what this interface should look like from someone who has. |
The TextInput and TextArea types have _input events, but with Checkbox and Dropdown they're called _change. This terminology difference confused me, so I think it should probably be unified. I personally like _change better but don't have a huge attachment to that name. It seems like _input is ok for everything except _textInput_input where the two inputs made me fail to notice it all on the first pass.
The text was updated successfully, but these errors were encountered: