esha / eventi Goto Github PK
View Code? Open in Web Editor NEWRich, declarative[, custom] event handling
Home Page: http://esha.github.io/Eventi
License: MIT License
Rich, declarative[, custom] event handling
Home Page: http://esha.github.io/Eventi
License: MIT License
This is unlikely to be worth the considerable effort it would probably take to implement (i.e. a complete rewrite of the parsing code). But in those few instances where you are registering multiple, related handlers, it might be nice to do things like:
Eventi.on('group:{type#tag other$1}#tag2', ...);
instead of
Eventi.on('group:type#tag#tag2 group:other#tag2$1', ...);
Just dropping the idea here to keep it in mind...
This might be as simple as overloading alias() to watch for DOM contexts that aren't eventi.fy'd, then automatically registering the declare.js' listener. Or maybe there should be an Eventi.declare(dom, '...') function?
For cross-cutting concerns like logging and debugging, it would be convenient to support registering listeners by category (or tag or whatever) alone, without limiting by type.
Eventi.on('group:', function(e) {
console.log('Group event: '+e.type, e);
});
This will require a) registering the handler for all known types on the target and b) watching all future listener registrations on the target for new types.
This will have the very obvious limitation that it will be entirely unable to intercept event types not otherwise being listened for by Eventi. Thus, we should never allow/imply support for an entirely empty listener definition (i.e. a "catch-all" listener).
This will require parser and support code for jQuery-style namespaces, as a base. Beyond that, we can probably just subsume their event system entirely, by replacing
Alternately, we could bridge the systems by wrapping those functions to ensure events fired in jQuery's manual event system are also fired in the DOM/Eventi and vice versa. The duplication is likely more wasteful and will require informing jQuery's Event builder of all of Eventi's custom properties, but it might cause fewer compatibility issues??
My current preference is to just overthrow their system.
Those needing to handle repeating events like "resize" typically want/should restrict execution. I'm envisioning a syntax like:
Eventi.on('resize%200', ...);// trailing execution
Eventi.on('resize%-200', ...);// leading execution
Should be fairly straightforward to implement via parser and on:handler hooks.
Currently, the following results in a combo event listener:
Eventi.on({ 'foo bar': fn });
It should be registering the fn as handler for both foo and bar, not foo+bar.
This would provide parity with how ... works. It would be a fairly handy shorthand for Event translation, as well as the potentially nifty feature of late resolution of handler functions (which essentially require off/on-again to change at the moment).
It would look like:
Eventi.on('keyup[ctrl-s]', 'service:save');// event translation
Eventi.on('validate', 'App.validate');// function resolution
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.