Sha256: fce4d6676809b3a586cdb53ce4ee2bb46724f13e4dab9d843828ba223ee8a778

Contents?: true

Size: 528 Bytes

Versions: 4

Compression:

Stored size: 528 Bytes

Contents

# frozen_string_literal: true

require 'dry/effects/effect'

module Dry
  module Effects
    module Effects
      class Async < ::Module
        Async = Effect.new(type: :async, name: :async)

        Await = Effect.new(type: :async, name: :await)

        def initialize
          module_eval do
            define_method(:async) { |&block| ::Dry::Effects.yield(Async.payload(block)) }
            define_method(:await) { |task| ::Dry::Effects.yield(Await.payload(task)) }
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dry-effects-0.1.1 lib/dry/effects/effects/async.rb
dry-effects-0.1.0 lib/dry/effects/effects/async.rb
dry-effects-0.1.0.alpha2 lib/dry/effects/effects/async.rb
dry-effects-0.1.0.alpha lib/dry/effects/effects/async.rb