-
Notifications
You must be signed in to change notification settings - Fork 295
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
Selecting Events with Style #1233
Comments
Hey, please give https://whatwg.org/faq#adding-new-features a read and improve the problem description based on that. |
@annevk, thank you. I enhanced the problem description. What do you think? |
I think the problem description still very much assumes a particular solution. Ideally it would not talk about that at all and instead focus on something people cannot do right now that you would like to solve. An alternative approach might be demonstrating through widespread library adoption and Stack Overflow questions that this is a pattern worth building into the web platform. |
Ah, thank you for clarifying. I revised the problem description again. |
Making CSS determine what JS function is going to execute is a big no-go IMO. You don't want to force style recalculation every time you need to read that |
In theory, stylesheets of event selectors, in the above cases CSS-based, would be runtime-compiled into functions which would invoke JavaScript functions as matching events were detected. The goal is to be able to efficiently filter and process streams of incoming events. My thoughts for the CSS-based proposal are that most Web developers already understand CSS selectors syntax and the CSSOM. The hope is that it would be easier for Web developers to modify stylesheets, as needed, than to modify event-filtering logic in JavaScript files. Also, selectors-based approaches would mean that filtering would be portable between clients and servers. Clients could update their filtering criteria, e.g., in response to users' UI gestures, and transmit updated selectors to servers.
Other possibilities include utilizing selectors from JSON querying languages, e.g., JSONiq and JQL. From the JSONiq specification:
|
What problem are you trying to solve?
How can criteria for filtering event streams and related program logic be made portable between clients and servers?
If able to transmit these criteria and related program logic between computers, fewer events would need be to be sent in event streams.
What solutions exist today?
Web developers often use JavaScript to filter DOM events and HTML server-sent events. For example:
At the WICG, there is also an Observable API under development. Here is an API example:
The DOM interface for events is
Event
and the HTML interface for server-sent events isEventSource
.Comparable models of events and event streams include XES, OCEL, xAPI, and Caliper.
Software libraries for reactive programming and event stream processing are myriad; some are listed here.
In .NET, there is an interface IQbservable<T> which enables client-side event-stream queries to be constructed in such a way that resultant queries can be processed server-side.
Event-stream querying languages include, but are not limited to: Stream Analytics Query Language, StreamSQL, Kafka KSQL, SQLStreams, SamzaSQL, and Storm SQL.
How would you solve it?
CSS is a Web Standard and Web developers are familiar with its syntax and semantics. Using CSS selectors, software developers could: (1) perform client-side or server-side event-stream filtering, and (2) transmit filtering criteria and related program logic between clients and servers. As CSS is modifiable at runtime via the CSSOM, event-stream filtering could be dynamic and responsive.
With respect to representing events, a number of non-mutually-exclusive options can be considered. Events could implement:
Event
.DocumentFragment
.boolean matches(DOMString selectors)
.Types of events could be identified by URI's, having both a namespace URI and a local name. Events could have attributes. Events could have classes or categories, resembling the publish-subscribe pattern. Events could have arguments or data. In markup, these features, all together, might resemble:
With such an XML-based model of events, CSS-based selectors can be utilized.
A special-purpose CSS property,
process
, could be used for expressing whether a client wants to subscribe to a selected event.Alternatively, this special-purpose property could be multi-valued and utilized to indicate which event processors or JavaScript functions to route selected events to:
For a concrete example, let us imagine a website which delivers real-time stock market data for visualization. There are roughly 2,400 companies traded on the New York Stock Exchange and there is far too much data to stream every update to every client for subsequent client-side filtering. As users dynamically select the stocks of interest to them, CSS filters could be created which describe the interesting events. These event selectors could be transmitted to servers so that users would need only receive those events interesting to them, the update events for those companies of interest to them.
and a corresponding CSS selector to select incoming updates for company
ABCD
might resemble:The text for the CSS selector
nyse|update:has(> [company='ABCD'])
could be sent to the server, alongside other selectors, to indicate which events to send to the client, which companies' stock market data that the user wanted to instantaneously visualize.Anything else?
Syntactic possibilities for CSS selectors could be explored with which to select events based on temporal patterns occurring in event streams.
Thank you.
The text was updated successfully, but these errors were encountered: