Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.
/ mobx-ruby Public archive

Implementation of MobX in Ruby (FUN PROJECT)

License

Notifications You must be signed in to change notification settings

d4rky-pl/mobx-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Implementation of MobX in Ruby (FUN PROJECT)

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages