Railway Flow-Based Programming with Flowex

Flow-Based Programming

Elixir GenStage

Railway FBP

defmodule Functions do
def add_one(number), do: number + 1
def mult_by_two(number), do: number * 2
def minus_three(number), do: number - 3
end
defmodule MainModule do
def run(number) do
number
|> Functions.add_one
|> Functions.mult_by_two
|> Functions.minus_three
end
end

Flowex

defmodule FunPipeline do
use Flowex.Pipeline
pipe :add_one
pipe :mult_by_two
pipe :minus_three
# functions` definitions are skipped
end
defmodule FunPipeline do
use Flowex.Pipeline
# ...
error_pipe :if_error

def if_error(error, struct, opts)
#...
end
defmodule ModulePipeline do
use Flowex.Pipeline
pipe AddOne
pipe MultByTwo
pipe MinusThree
end
defmodule FunPipeline do
use Flowex.Pipeline
pipe :add_one, 1
pipe :mult_by_two, 3
pipe :minus_three, 2
error_pipe :if_error, 2
# ...
end

Conclusion

--

--

Software engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store