0.0.21 • Published 30 days ago

intertalk v0.0.21

Weekly downloads
-
License
MIT
Repository
github
Last release
30 days ago

InterTalk

Table of Contents generated with DocToc

InterTalk

API

  • emit_on_event: ( element, event_name, note_name ) -> (only in browser): given a DOM element, a DOM event_name and a note name, when a matching event is triggered on the element, emit a note with $key: note_name and $value: event

    • when emit_on_event is called with the arguments ( event_name, note_name ) then the event listener will be attached to document: IT.emit_on_event div_1, 'click', 'bar' will be triggered when clicking on the div_1 element only, but IT.emit_on_event 'click', 'bar' will be triggered by any click anywhere within the browser document window.
  • unsubscribe: ( listener ) ->: unsubscribe listener from all notifications.

  • unsubscribe: ( $key, listener ) ->: unsubscribe listener from notifications matching $key.

Is Done

  • + allow to use Map (or other suitable replacement) instead of WeakMap where Symbols 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)
  • + 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), store WeakSets as values,
    • likewise, make Intertalk#any_listeners a WeakMap
    • may later want to cache association between $keys and listeners to avoid to re-construct sets
  • + implement on_any() or similar to catch all emitted notes
  • + implement off() to unsubscribe a listener
  • + implement signature off $key, listener to unsubscribe a listener only from matching notes
  • + implement on_unhandled() or similar to catch all notes that were emitted but not listened to

To Do

  • event namespacing
  • in emit_on_event(), allow to transform / add attributes to outgoing note
  • implement once() for listeners that should only receive a single note (this requires implementing off()) 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 (dubbed control or ctrl) that contains methods to unsubscribe, cancel &c, or (2) describe how to achieve this by using the intertalk instance's methods

    • off: () ->: unsubscribe this listener from this $key
    • off_all: () ->: unsubscribe this listener from all keys, including any and fallback subscriptions
  • implement note cancellation / note rewrite

0.0.20

30 days ago

0.0.21

30 days ago

0.0.19

30 days ago

0.0.17

1 month ago

0.0.18

1 month ago

0.0.16

1 month ago

0.0.13

1 month ago

0.0.14

1 month ago

0.0.15

1 month ago

0.0.10

1 month ago

0.0.11

1 month ago

0.0.12

1 month ago

0.0.3

1 year ago