Is promise concept available in ruby?

ruby promise gem
ruby future
javascript promise
ruby threads
ruby fiber

I'm Just wondering, Is there a chaining concept in ruby. I wanted to execute series of async tasks or methods one after the other. Is it possible?

Thanks, Ravi


You might want to create a process class, something like:

class MyProcess

  PROCESS_STEPS = %w(
    step_one
    step_two
    step_three
  )

  class << self 

    def next_step
      new.next_step
    end

  end # Class Methods

  #======================================================================
  # Instance Methods
  #======================================================================

    def next_step
      PROCESS_STEPS.each do |process_step|
        send(process_step) if send("do_#{process_step}?")
      end
    end

    def step_one
      # execute step one task
    end

    def do_step_one?
      # some logic
    end

    def step_two
      # execute step two task
    end

    def do_step_two?
      # some logic
    end

    def step_three
      # execute step three task
    end

    def do_step_three?
      # some logic
    end

end

You would probably put that in:

app 
 |- processes
 |   |- my_process.rb

Then, at the end of each task, do something like:

MyProcess.next_step 

Is promise concept available in ruby?, Luckily, promises were something which allowed us to get a huge step apps - Assets which provides an overview of assets available for the owner, The idea is like with Enumerable collections in Ruby - you transform  Today we'll pick up from yesterday discussing the concept and the art of Promises. What is a promise. As defined by the Mozilla, a Promise object is used for handling asynchronous computations which has some important guarantees that are difficult to handle with the callback method (the more old-school method of handling asynchronous code).


Javascript, where Promises were first introduced, is also synchronous, promises being an abstraction over callbacks in the strictest sense

There are concurrency libraries for Ruby, some of which capture the spirit of Promises to a certain extent, a google search for promise.rb yields some promising results:

https://github.com/lgierth/promise.rb https://github.com/ruby-concurrency/concurrent-ruby

Perhaps these are not idiomatic ruby, but they do offer some useful paradigms

The Beginners Guide to jQuery.Deferred and Promises for Ruby , num = NaiveLazy::Promise.new { 3 } => #<NaiveLazy::Promise directly convert functional concepts into Ruby, but by playing to Ruby's strengths, you can often  These features have been discussed in the chapter Object Oriented Ruby. An object-oriented program involves classes and objects. A class is the blueprint from which individual objects are created. In object-oriented terms, we say that your bicycle is an instance of the class of objects known as


As far as i can tell, promise.rb is the most commonly used gem for an async mechanism adhering to the js Promise/A+ standard.

This article does a decent job of introducing it: https://medium.com/@gauravbasti2006/lets-keep-our-promise-in-ruby-e45925182fdc

Ruby Best Practices: Increase Your Productivity, The Promise object represents the eventual completion (or failure) of an completed successfully. rejected: meaning that the operation failed. using Promise and XMLHttpRequest to load an image is available at the MDN  Available to Promise or Safety Stock? Some businesses mistake available to promise for safety stock, but there are key differences between the two.Safety stock refers to keeping a certain amount of additional inventory above the necessary stock in case of an unexpectedly large order or delay in shipment.


Promise, Promises are chained using the then method. The result of a call to then is always another promise. Promises are resolved asynchronously (with respect to the  The caveat is that the actual data isn’t available yet. It will become available when the request completes and a response comes back from the web service. In the meantime, the Promise object acts


Class: Concurrent::Promise, At the risk of another cheesy analogy, the concepts of fabulous tools and rapid development leading to Is it any wonder that since 2006, IBM has had a DB2 on Rails toolkit available to enable Ruby Okay, I promise no more cheesy jokes​. Available-to-promise (ATP) is a business function that provides a response to customer order inquiries, based on resource availability. It generates available quantities of the requested product, and delivery due dates. Therefore, ATP supports order promising and fulfillment, aiming to manage demand and match it to production plans.


Beginning DB2: From Novice to Professional, In computer science, future, promise, delay, and deferred refer to constructs used for A somewhat similar concept future was introduced in 1977 in a paper by Henry implementation of promise pipelining only became publicly available with the For Ruby: Promise gem; libuv gem, implements promises; Celluloid gem,  The promises of a chain are nested like Russian dolls, but get popped like the top of a stack. The first promise in the chain is most deeply nested and is the first to pop. (promise D, (promise C, (promise B, (promise A) ) ) ) When a nextValueis a promise, the effect is a dynamic replacement.