flatMapResult(_:)

When the current EventLoopFuture<Value> is fulfilled, run the provided callback, which performs a synchronous computation and returns either a new value (of type NewValue) or an error depending on the Result returned by the closure.

EventLoopFuture+AssumeIsolated.swift:407
func flatMapResult<NewValue, SomeError>(_ body: @escaping (Value) -> Result<NewValue, SomeError>) -> EventLoopFuture<NewValue>.Isolated where SomeError : Error

Parameters

body

Function that will receive the value of this EventLoopFuture and return a new value or error lifted into a new EventLoopFuture.

Returns

A future that will receive the eventual value.

Operations performed in flatMapResult should not block, or they will block the entire event loop. flatMapResult is intended for use when you have a data-driven function that performs a simple data transformation that can potentially error.