Skip to content

peek : Use

function Fusion.peek<T>(
    target: UsedAs<T>
): T

Extracts a value of type T from its input.

This is a general-purpose implementation of Use. It does not do any extra processing or book-keeping beyond what is required to determine the returned value.

Specific implementations

If you're given a specific implementation of Use by an API, it's highly likely that you are expected to use that implementation instead of peek().

This applies to reusable code too. It's often best to ask for a Use callback if your code needs to extract values, so an appropriate implementation can be passed in.

Alternatively for reusable code, you can avoid extracting values entirely, and expect the user to do it prior to calling your code. This can work well if you unconditionally use all inputs, but beware that you may end up extracting more values than you need - this can have performance implications.


Parameters

target : UsedAs<T>

The abstract representation of T to extract a value from.


Returns -> T

The current value of T, derived from target.


Learn More

Back to top