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
EventSource: promises, priorities and execution breaks #2273
Conversation
…h $.type. Add $.Promise proxy. Implement support for promises in EventSource. Implement ability to abort events as well as prioritize events.
I forgot to remove |
I guess a simple tutorial page on EventSource could be also useful... I was also thinking about splitting I even more think about splitting Edit: truth is, removeHandler is available anyway.. |
Also, I noticed that
|
Wow, there's a lot going on here!
I don't think we should be adding complexity without strong scenarios to back it up. Also, the scenarios can help us decide what tradeoffs to make. Thank you! |
These two features were added after I was trying to re-use this event system in a more complex architecture. Although these do not necessarily bring immediate merit to OSD, I needed these for a fully-fledged event system. Exiting event from a callback Also, one could elegantly remove default events without actually removing them by creating a higher-priority callback that exits the event. This could (temporarily) bypass OSD features via events. This would be even more powerful if events in OSD had defined priority numbers. Promises in EventSource
Since OSD now recognizes Recognizing async function as a function
Although it was allways possible to create a function that returns its logic in a promise and pass it as a callback, still, you had to go and implement it. Wouldn't it be better to create |
Thank you for the explanations!
My concern here is whether there are any internal systems in OSD that depend on those events getting through. We've always had the assumption that they would, so if that were to change, we'd want to really make sure it's not going to cause problems. From an API standpoint, I feel like the existing Again, I haven't examined all the code, but I could also imagine situations where So... It seems to me more cost/benefit research is needed on this.
I'm also concerned that this might disrupt internal OSD things. Again, we'd just have to look I guess. I'm also not sure there's a scenario where it's necessary to do this sort of event chaining within OSD... There's nothing stopping you from event chaining inside your own handler. I guess the scenario is when you're going to need to do something lengthy, like hit a server, before telling OSD it's okay to proceed. Do you have a specific scenario like that in mind? One of OSD's top priorities is performance and responsiveness. The bedrock of that is for every action, we do what we can with the info we have at the moment. I don't like the idea of potentially adding hiccups between a user action and OSD responding to it. A better design pattern is to handle this action with the info you have and fire off whatever async things you need in order to have the right info you may want for the next action. Anyway, I'd love to hear about the specific scenario!
So reverting In general, I'm not in favor of adding things into OSD that can be handled outside of OSD; otherwise, the library just grows in complexity. If the scenarios you're interested in can be done outside of OSD using the existing API, I think we should stick with that. |
Ok, let's remove it for now. I guess using a flag is also an option.
I was on the other hand concerned about not having this would disrupt things. My primary motivation for adding this was that one would expect its presence in the API. We can remove it. We can move it to a new method
Keeping disjunct |
Cool. We can always revisit later if need be.
I think we should keep the API focused on real-time actions. If async stuff needs to be introduced, it should be on a case-by-case basis, or, ideally, something the developer does outside of the internal OSD workings. That said, if you have an example of a scenario where not supporting promises in events would cause disruptions, I'd love to hear about it. Otherwise, yes, let's set that aside.
The |
It is almost the same. There are some differences but the main idea is that both return promise because of the (backward) compatibility of this approach. Should be OK now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thank you for working with me on what to include here. Lots of factors go into what's best for OSD. ❤️
* master: (276 commits) Changelog for #2280 and #2238 remove trailing space fix problem with click precision on ReferenceStrip Changelog for #2273 Also add documentation for tileRetryDelay try fix with check for null and undefined fix build error Add tileRetryMax documentation. Revert async support and event breaking support in EventSource. Changelog for #2276 add box-sizing property to the navigator display region Implement support for async function and promise type recognition with $.type. Add $.Promise proxy. Implement support for promises in EventSource. Implement ability to abort events as well as prioritize events. Changelog for #2270 issues/2192 fix. Starting 4.0.1 Version 4.0.0 JSDoc fixes Changelog for #2256 Changelog for #2249 removed polling vs resizeviewer option from demo ...
Adding support for type detection:
async function
andpromise
.New features in EventSource:
ability to wait for promise-returning functions if specified(still documented in the original PR)ability to exit raised event for all unfinished callbacks(still documented in the original PR)