class Mon::Monad::React

The React class is the parent of Reactron and Reactor. The key difference between the two is the presence of the << operator. The value of a Reactor is derived from a Reactron, and cannot be directly changed. If viewed as a tree, Reactrons are the root, and only the root may be changed.

However, we can have more than one root! m = React[2] # ==> Reactron[2] n = React[10] # ==> Reactron[10] v = m * n # Currently v == Reactor[20] n << 5 # Now v == Reactor[10]

Usage of React is straightforward: r = React[some_value]

Public Class Methods

[](obj) click to toggle source

Wrap a value in a Reactron: <tt>r = React # ==> Reactron

# File lib/monads/reactron.rb, line 40
def self::[] obj
  if (obj.is_a? Proc)
    Reactor[obj]
  else
    Reactron[obj]
  end
end
valid?(v) click to toggle source
# File lib/monads/reactron.rb, line 52
def self::valid?(v)
  v.is_a? React
end