middleware icon indicating copy to clipboard operation
middleware copied to clipboard

Immutable Stacks or ability to easily copy a stack

Open mmmries opened this issue 11 years ago • 0 comments

I have a project where I would like to setup a reference stack and then make a few different stacks that differ in only a small way from the reference stack. For instance:

stack = Middleware::Builder.new do
  use Trace, "A"
  use Trace, "B"
end

stack2 = stack.dup
stack2.insert_after(2, Trace, "C")

stack2.call
--> A
--> B
--> C
<-- C
<-- B
<-- A

But currently ater I run the above code and I call stack.run, it gives me the same output that stack2 gave me.

If I open a pull request to fix this would you be open to supporting this feature?

mmmries avatar Dec 16 '14 14:12 mmmries