render.transformer.resolve_value_fn

render.transformer.resolve_value_fn(value_fn)

Resolve the value function

This function is used to resolve the value function (value_fn) to an object of type IT. If the value function is asynchronous, it will be awaited. If the value function is synchronous, it will be called.

While always using an async method within an output transform function is not appropriate, this method may be safely used to avoid boilerplate.

Replace this:

if is_async_callable(_fn):
    x = await _fn()
else:
    x = cast(ValueFnSync[IT], _fn)()

With this:

x = await resolve_value_fn(_fn)

Parameters

value_fn : ValueFn[IT]

App-supplied output value function which returns type IT. This function can be synchronous or asynchronous.

Returns

: IT

The resolved value from value_fn.