Project

mobx-ruby

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
An implementation of Mobx state management library
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 0.8
~> 10.1
~> 3.5
~> 0.9
 Project Readme

Build Status Coverage Status Gem Version

Mobx-ruby

An implementation of MobX written in Ruby.

THIS IS JUST A FUN PROJECT!! It is not production ready.

API

## Observables in classes

class ExampleClass
  include Mobx::Extension
  observable :foo, 123
end

example = ExampleClass.new

## Autorun

runner = Mobx.autorun do
  puts "Hello: #{example.foo}"
end

example.foo = 456
# > Hello: 456
example.foo = 789
# > Hello: 789

## Actions (transactions)

Mobx.action do
  example.foo = 123
  example.foo = 999
  example.foo = 1337
end
# > Hello: 1337

## Disposing of autoruns

runner.dispose

## Reactions

Mobx.reaction -> { example.foo } do
  puts "This doesn't look like anything to me"
end
# > This doesn't look like anything to me

example.foo = 333
# > This doesn't look like anything to me

TODO

  • observables are not infectious (observing an array or object will not trigger reactions, not sure how to handle this yet)
  • naming conventions, I was experimenting too much and I'm not happy with the results