Commit Graph

18 Commits (events)

Author SHA1 Message Date
Mike Gerwitz b868a2da80 Eventable common tests for #{on,{add,remove}Listener} 2014-08-10 22:57:47 -04:00
Mike Gerwitz 0d40ca6f4a Eventable conformance tests now run by Evented
This includes cleaning up the test case to remove tests now covered by the
conformance test case, and altering the implementation slightly for
conformance.
2014-08-10 18:03:41 -04:00
Mike Gerwitz aab86a47cd Initial Eventable conformance test case (#on/#addListener)
These conformance test cases will be an excellent disciplinary tool,
ensuring that any implementation of Eventable conforms strictly to its
specification; this will provide developers guarantees that the
implementation will work as expected polymorphically.
2014-08-10 18:02:50 -04:00
Mike Gerwitz a2deba59ad Evented#on to throw {Error=>ReferenceError} on undefined event id 2014-08-10 14:20:41 -04:00
Mike Gerwitz 914e4eed78 Added Evented#unhookEvent for logic overide 2014-08-10 14:20:41 -04:00
Mike Gerwitz 701a49226c Evented documentation elaborating on Node.js compatibility
Some of these features will be introduced into jsTonic through additional
traits: for example, the magic `error` event that produces exceptions if
unhooked can be implemented using stackable traits or Evented trait
overrides (the former is superior and more generalized/independent).
2014-08-10 14:20:41 -04:00
Mike Gerwitz c8bddfbaeb Eventable and Evented no longer include #hooksEvent
This is introspection, which can be provided elsewhere or by specific
implementations. Together with the documented requirement (in Eventable#on)
that listeners must be notified of automatic un-hooking, and that systems
handling listeners will always be aware of when listeners are
hooked/unhooked, this method should not be necessary.

Including this method in Eventable also introduces incompatibility with
Node.js' Event API, which is undesirable.
2014-08-10 14:20:41 -04:00
Mike Gerwitz 7fa2a296d2 Eventable interface with extensive specification 2014-08-10 14:20:41 -04:00
Mike Gerwitz bac61c3f08 Documented Evented differences from Node.js events 2014-08-10 14:20:41 -04:00
Mike Gerwitz e55288c989 Evented listener metadata now distinct per instance 2014-08-10 14:20:41 -04:00
Mike Gerwitz eeea892967 Exposed Evented#_hooksEvent as public #hooksEvent 2014-08-10 14:20:41 -04:00
Mike Gerwitz 66e3d5b1ef Prohibited duplicate listeners of the same event 2014-08-10 14:20:41 -04:00
Mike Gerwitz 875c43cee4 Added Evented#addListener as #on alias
Consistent with Node.js' event API
2014-08-10 14:20:41 -04:00
Mike Gerwitz 74ccbff716 Consistent terminology in Evented docblocks and tests 2014-08-10 14:20:41 -04:00
Mike Gerwitz a543d3f950 Formal Big O/Theta notation in docblocks for Evented trait
This annotation is my own---there is not currently a system, insofar as I
know, that uses it. I'll be further formalizing things like this as I go,
but the idea is that I wish to provide asymptotic computational complexity
for all algorithms. Usually, these will be in Big O notation, which is
used (for better or for worse) to denote the upper bound of asymptomatic
growth. I will provide as tight of estimates as I can. Where the estimates
between upper and lower bounds differ significantly, I will provide both;
where they converge strongly, I'll use Big Theta notation---denoted by a
`@Theta` annotation---except in the case of constant time, for which I will
simply stick with Big O.
2014-08-10 14:20:41 -04:00
Mike Gerwitz 981d8b923a Evented#removeListener
As a conscious TODO: need to properly handle attaching the same event
listener multiple times (define its behavior), and maybe even provide an API
to configure that behavior in some way.
2014-08-10 14:20:41 -04:00
Mike Gerwitz 7baff379ce Using ES6 features through Traceur to cut down on verbosity
It will take some getting used to (and it's a little sad to see some of the
long-standing conventions of ECMAScript vanish before my eyes), but it's
great thus far.
2014-08-10 14:20:39 -04:00
Mike Gerwitz 2942f153db Evented trait with basic functionality
This provides the core of the trait, with support for event definitions and
hooks.
2014-08-10 14:20:09 -04:00