Skip to content

Support buffered/delayed calls? #7

@tmontes

Description

@tmontes

Example:

w = Wiring()
w.this()

def my_callable():
    print('called!')

w.wire.this.calls_to(my_callable)

In the example above, the unwired call w.this() has no effect. Would it be useful to support "buffering" of calls such that the previous example would "remember" the unwired call in w.this() and later call my_callable at wiring time?

Thoughts:

  • If possible, Wiring instances should default to "not doing this", behaving like "event systems" / "pub-sub systems" that just throw away "unhandled "events" / "unsubscribed messages".
  • Probably related to Support min/max callee count on callables. #3 (optional min/max callee setting) in the sense that delayed callee calling should be triggered, if activated, only when the min callee count is reached (or on the first wiring, if min is unset).
  • If possible, activating this behaviour should be configurable in "how many" buffer/delayed calls to keep track of.
  • Configurable at the Wiring instance level and at the individual callable level?

API possibility:

  • Have a track_unwired_calls Wires initialisation argument:
    • Defaults to 0.
    • If set to a positive integer n: will track that amount of unwired calls.
    • If set to True: will track an unlimited number of unwired calls.
    • If set to False: raise an exception if an unwired callable is called (conflict with idea in Support min/max callee count on callables. #3, needs thinking).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or capability.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions