-
-
Notifications
You must be signed in to change notification settings - Fork 830
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
Implement UI event dispatcher/listener #4492
Conversation
Putting this on hold until I can determine the necessity of this change. I am not convinced that listening for elements and page changes is the correct approach. |
I don't have a better solution for avoiding this infinite loop, this loop boosts up my CPU usage, memory usage and starts to lag after few hours. Event listeners are basically used to solve these kinds of issues. With this PR that infinite loop code can be replaced with this event listener. Also there is no element listener in my PR. This This implementation is very much accepted in Stack Over Flow. If you dont want to use <Route path="/" component={App} onEnter={() => Event.dispatch("location", "", { location })} /> |
I was referring to plugins using event listeners to know when to manipulate the dom. It's not a very react way of doing things. However, I get your point, and we should support someone like this to avoid the hacks you describe. It would be possible to insert something like this into a plug-in, but an officially supported way is probably better. I'll take another look at this on Monday. |
* page change event * expose event to plugin api * Update UIPluginApi.md * Add to example plugin --------- Co-authored-by: WithoutPants <[email protected]>
Implemented events
Now Stash ui client can create
events
that can be used by both plugins and stash ui client to do stuffs on a event. For now I have only implementedstash:location
event which gets triggered on route change.Plugin side usage for the event
stash:location
Stash Userscript library uses
setInterval
of100ms
to check for page (href) change, which is performance intense they had no other choice. So now plugins like that can use this event which is very performance friendly. Its not just for page change event devs can implement more useful events like this.Stash ui client usage for creating a event
To create a
stash:page:scenes
event, put this code herePlugin side code for above event
Note: Stash ui client can also listen for this event by using
Event.addEventListener