• Beta

    A helper utility function for use with the functional API that returns the previous state from the checkpoint from the last invocation of the current thread.

    This function allows workflows to access state that was saved in previous runs using entrypoint.final.

    !!! warning "Beta" The Functional API is currently in beta and is subject to change.

    Type Parameters

    • StateT

      The type of the state that was previously saved

    Returns StateT

    The previous saved state from the last invocation of the current thread

    Example

    const previousState = getPreviousState<{ counter: number }>();
    const newCount = (previousState?.counter ?? 0) + 1;