def flat_map # rubocop: disable Metrics/MethodLength
      promise = Promise.new(@options)
      on_complete_match do |m|
        m.case(Fear::Failure) { |failure| promise.complete!(failure) }
        m.success do |value|
          begin
            yield(value).on_complete { |callback_result| promise.complete!(callback_result) }
          rescue StandardError => error
            promise.failure!(error)
          end
        end
      end
      promise.to_future
    end
def flat_map # rubocop: disable Metrics/MethodLength
      promise = Promise.new(@options)
      on_complete_match do |m|
        m.case(Fear::Failure) { |failure| promise.complete!(failure) }
        m.success do |value|
          begin
            yield(value).on_complete { |callback_result| promise.complete!(callback_result) }
          rescue StandardError => error
            promise.failure!(error)
          end
        end
      end
      promise.to_future
    end
Creates a new future by applying a block to the successful result of
 this future, and returns the result of the function as the new future.
 If this future is completed with an exception then the new future will
 also contain this exception.

 @yieldparam [any]
 @return [Fear::Future]

 @example
   f1 = Fear.future { 5 }
   f2 = Fear.future { 3 }
   f1.flat_map do |v1|
     f1.map do |v2|
       v2 * v1
     end
   end