Deferred

class jsonapi_serde.deferred.Deferred(yielder: Callable[[...], jsonapi_serde.deferred.T], *args, **kwargs)

A deferred object encapsulates a lazy evaluated value. It takes a function that yields the value for its constructor argument, and it behaves as a callable by which it resolves to the yielded value.

An attribute access to a Deferred recursively results in another Deferred that encapsulates the access to the attribute.

Parameters
  • yielder (Callable[..., T]) – a callable that resolves the value.

  • args – positional arguments for the yielder.

  • kwargs – keyword arguments for the yielder.

class jsonapi_serde.deferred.Promise

A Promise is a special case of Deferred, in that you can inject the resolved value directly into the object by calling set().