redux logic for your ruby experiments
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib
spec
.gitignore
.reek
.rspec
.rubocop.yml
CODE_OF_CONDUCT.md
Gemfile
Gemfile.lock
Guardfile
LICENSE
README.md
Rakefile
dev.Dockerfile
docker-compose.yml
r2x.gemspec
r2x.png

README.md

r2x

r2x (/ɑːrˈskwerɛks/)

An opinionated redux-like state container for ruby apps.

Setup

Add to your Gemfile

gem 'r2x'

Usage

Define actions and reducers as such:

state = {
  tasks: []
}

R2x::Store.build(state) do |s|
  actions do
    tasks :add_task, :remove_stask
    task :toggle
  end

  reducers do
    tasks do |state, action|
      case action[:type]
      when :add_task
        state[:tasks] << action[:value]
      else
        state
      end
    end

    task do |action|
      # And so on..
    end
  end
end

Development

If you are into docker, you just need to:

$ docker-compose build

after you build the image, you can get into test service:

$ docker-compose run --rm test bash

And run the current specs rspec.