SlideShare a Scribd company logo
1 of 37
Download to read offline
mobx-ruby
ruby
ruby conf 2017
Ruby
80% &CTO
,
80%
•
• RubyConf China
• (DJI) Ruby
•
• spreadsheet
• web
• mobx-ruby
• mobx-ruby
•
•
• callback
• + ( , )
mobx
spreadsheets
an example
AngularJS
•
• <=> UI
• ( scope apply & digest)
•
• zone.js( )
ReactJS
•
• , UI
• DOM, diff UI
VueJS
• mobx
• data: {}
• , UI
Ruby mobx
mobx
• ( observable value )
• ( computed value )
• ( autorun )
mobx-ruby
# basic.rb
require 'mobx'
class A
include Mobx::Extension
observable :foo, 1
end
a = A.new
## Autorun
runner = Mobx.autorun do
puts "Hello: #{a.foo}"
end
a.foo = 2
# > Hello: 2
a.foo = 3
# > Hello: 3
# ai.rb
require 'mobx'
require 'byebug'
class A
include Mobx::Extension
observable :foo, 1
observable :bar, 2
observable :nocare, 10
end
a = A.new
runner = Mobx.autorun do
puts "Hello foo: #{a.foo} bar: #{a.bar}"
end
# > Hello foo: 1 bar: 2
a.foo = 2
# > Hello foo: 2 bar: 2
a.bar = 4
# > Hello foo: 2 bar: 4
a.nocare = 10
#
# transaction.rb
require 'mobx'
require 'byebug'
class A
include Mobx::Extension
observable :foo, 1
end
a = A.new
runner = Mobx.autorun do
puts "Hello: #{a.foo}"
end
# > Hello: 1
Mobx.transaction do
a.foo = 2
a.foo = 3
a.foo = 4
end
# > Hello: 4
mobx-ruby (
)
mobx-ruby
•
•
•
• class Observable
•
•
• class Reaction
•
• class Autorun
•
• ,
• Observable
• Autorun , Observable
•
• Observable ,
• transaction
• ,
• , autorun
• mobx
• ,
• redux
• ,
• rxjs
• , :)
redux
3 ~ 15
•
• actioncable opal , rails
‘meteor’
# This is just a simple example for actioncable server
require 'mobx'
class Todolist
include Mobx::Extension
observable :todos, []
def todo_length
todos.length
end
end
todolist = Todolist.new
runner = Mobx.autorun do
ActionCable.broadcast 'todo_channel', { todos:
todolist.todos, length: todolist.todo_length }
end
todolist.todos << ' '
# > todo_channel
todolist.todos << ' '
# > todo_channel
todolist.todos << ' '
# > todo_channel
• callback
•
# This is just a simple example for callback
require 'mobx'
class ModelA
include Mobx::Extension
observable :a, 1
end
class ModelB
def initialize
@b = nil
end
end
a = ModelA.new
b = ModelB.new
Mobx.autorun do
b.b = a.a + 1
b.save!
end
a.a = 2
# b a , callback
• Rails
•
# This is just a simple example for redis cache
require 'mobx'
class CacheListener
include Mobx::Extension
observable :avatar, '/uploads/xx.jpg'
end
cache = CacheListener.new
runner = Mobx.autorun do
Redis.set(:avatar_key, cache_listener.avatar)
end
cache.avatar = '/uploads/new_avatar.jpg'
# > Cache
mobx-ruby
• ( ) -
• ( )
• ( )
• ( ) -
• ( TODO )
• ( TODO )
• ( TODO )
• ( TODO )
• 2018 1
mobx-ruby
• RxJava( ) 27k
•
•
• Ruby
lyfi2003
: mobx
• rails-template
• github: 80percent/rails-template
• rails5.x
• : , ssl, backup, ,
• wechat-weapp-mobx
• github: 80percent/wechat-weapp-mobx
•
RubyChina ID: lyfi2003

More Related Content

What's hot

Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"
EPAM Systems
 

What's hot (7)

aiohttp intro
aiohttp introaiohttp intro
aiohttp intro
 
Rubyslava + PyVo #48
Rubyslava + PyVo #48Rubyslava + PyVo #48
Rubyslava + PyVo #48
 
Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"
 
What Is Async, How Does It Work, And When Should I Use It?
What Is Async, How Does It Work, And When Should I Use It?What Is Async, How Does It Work, And When Should I Use It?
What Is Async, How Does It Work, And When Should I Use It?
 
mruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなしmruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなし
 
MacRuby to The Max
MacRuby to The MaxMacRuby to The Max
MacRuby to The Max
 
Mac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. LimMac ruby to the max - Brendan G. Lim
Mac ruby to the max - Brendan G. Lim
 

Similar to mobx-ruby rubyconf china 2017 李亚飞演讲

The Future of Rubymotion
The Future of RubymotionThe Future of Rubymotion
The Future of Rubymotion
Clay Allsopp
 
Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門
Wen-Tien Chang
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2
Wyatt Fang
 
Learning to code for startup mvp session 3
Learning to code for startup mvp session 3Learning to code for startup mvp session 3
Learning to code for startup mvp session 3
Henry S
 
The Architecture of PicCollage Server
The Architecture of PicCollage ServerThe Architecture of PicCollage Server
The Architecture of PicCollage Server
Lin Jen-Shin
 
Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010
Dirkjan Bussink
 

Similar to mobx-ruby rubyconf china 2017 李亚飞演讲 (20)

Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2
 
Rails Performance
Rails PerformanceRails Performance
Rails Performance
 
The Future of Rubymotion
The Future of RubymotionThe Future of Rubymotion
The Future of Rubymotion
 
Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2
 
Rails 3 (beta) Roundup
Rails 3 (beta) RoundupRails 3 (beta) Roundup
Rails 3 (beta) Roundup
 
MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?MacRuby: What is it? and why should you care?
MacRuby: What is it? and why should you care?
 
The details of CI/CD environment for Ruby
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for Ruby
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar BatsovRuby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
Ruby 4.0 To Infinity and Beyond at Ruby Conference Kenya 2017 by Bozhidar Batsov
 
Node.js Performance Case Study
Node.js Performance Case StudyNode.js Performance Case Study
Node.js Performance Case Study
 
Learning to code for startup mvp session 3
Learning to code for startup mvp session 3Learning to code for startup mvp session 3
Learning to code for startup mvp session 3
 
The Architecture of PicCollage Server
The Architecture of PicCollage ServerThe Architecture of PicCollage Server
The Architecture of PicCollage Server
 
MacRuby, an introduction
MacRuby, an introductionMacRuby, an introduction
MacRuby, an introduction
 
Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010
 
Upgrading to rails3
Upgrading to rails3Upgrading to rails3
Upgrading to rails3
 
Rubinius 1.0 and more!
Rubinius 1.0 and more!Rubinius 1.0 and more!
Rubinius 1.0 and more!
 
Server-Side JavaScript Developement - Node.JS Quick Tour
Server-Side JavaScript Developement - Node.JS Quick TourServer-Side JavaScript Developement - Node.JS Quick Tour
Server-Side JavaScript Developement - Node.JS Quick Tour
 

Recently uploaded

Microsoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfMicrosoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdf
Overkill Security
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 

Recently uploaded (20)

Microsoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdfMicrosoft BitLocker Bypass Attack Method.pdf
Microsoft BitLocker Bypass Attack Method.pdf
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
The Ultimate Prompt Engineering Guide for Generative AI: Get the Most Out of ...
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 

mobx-ruby rubyconf china 2017 李亚飞演讲