intertalk v0.0.21
InterTalk
Table of Contents generated with DocToc
InterTalk
API
emit_on_event: ( element, event_name, note_name ) ->(only in browser): given a DOMelement, a DOMevent_nameand anotename, when a matching event is triggered on the element, emit a note with$key: note_nameand$value: event- when
emit_on_eventis called with the arguments( event_name, note_name )then the event listener will be attached todocument:IT.emit_on_event div_1, 'click', 'bar'will be triggered when clicking on thediv_1element only, butIT.emit_on_event 'click', 'bar'will be triggered by any click anywhere within the browser document window.
- when
unsubscribe: ( listener ) ->: unsubscribelistenerfrom all notifications.unsubscribe: ( $key, listener ) ->: unsubscribelistenerfrom notifications matching$key.
Is Done
- + allow to use
Map(or other suitable replacement) instead ofWeakMapwhereSymbols are not allowed as keys (true for Firefox at least up to v124.0.1) - + fix some names:
- class
Async_events(->Intertalk?) - class
AE_Event(->Note) - instance
ae_event(->note?) - class
AE_Event_results(->Results) - datom key
ae_event-results($results)
- class
- + export singular instance of
Intertalk, provide other names as properties (?) - + remove ability to discover suitably named note listeners on objects as it only leads to complications
- + reconstruct listener registration:
- in a
Map(needed for symbol$keys), storeWeakSets as values, - likewise, make
Intertalk#any_listenersaWeakMap - may later want to cache association between
$keys andlisteners to avoid to re-construct sets
- in a
- + implement
on_any()or similar to catch all emittednotes - + implement
off()to unsubscribe a listener - + implement signature
off $key, listenerto unsubscribe a listener only from matching notes - + implement
on_unhandled()or similar to catch allnotes that were emitted but not listened to
To Do
- – event namespacing
- – in
emit_on_event(), allow to transform / add attributes to outgoingnote – implement
once()for listeners that should only receive a singlenote(this requires implementingoff()) implement returning a 'command' instance that may contain the listener's results, if any, but also controls how to deal with the current note and whether or not to unsubscribe the listener. Alternatively, either (1) pass in a second argument (dubbedcontrolorctrl) that contains methods to unsubscribe, cancel &c, or (2) describe how to achieve this by using theintertalkinstance's methodsoff: () ->: unsubscribe this listener from this$keyoff_all: () ->: unsubscribe this listener from all keys, includinganyand fallback subscriptions
– implement note cancellation / note rewrite