SlideShare uma empresa Scribd logo
1 de 19
© Gofore Oy 2016 •
Synchronizing Application State
Using Virtual DOM Trees
Jari-Pekka Voutilainen,
Tommi Mikkonen and
Kari Systä
Jari-Pekka Voutilainen
Me
• PHD student at Tampere University of Technology
• Researched Browser applications since 2011
• Currently working at Gofore Ltd.
• Finnish software consultation company
• @zharktas in twitter
• Jari.Voutilainen@iki.fi
Jari-Pekka Voutilainen 2
Agenda
• Background
• Liquid applications
• Browser application state
• Virtual DOM
• Serializing browser state
• Demos
Jari-Pekka Voutilainen 3
Background
• Multiple devices
• Applications need to be installed multiple times
• Applications might be in different states
• Applications require large scale backend for storing state
• Transferring application between devices is not currently feasible.
Jari-Pekka Voutilainen 4
Liquid Applications
• Defined as applications that can flow from device to device.
• Three subsystems were identified:
• User interface
• Persistent data and content
• State of the application
Jari-Pekka Voutilainen 5
Liquid applications
• This study focuses on the state of the applications.
• Multiple options for migrating browser application state:
• Complete memory space of the browser
• Pre-defined set of variables
• Determining relevant state from the application
Jari-Pekka Voutilainen 6
Liquid Application Framework
• The goal is to make developing liquid applications simple.
• Developers had to implement specific APIs for application transfer.
• Application should not be designed to be liquid.
• Basis should be in existing browser implementations.
• Liquid applications do not need to be installed everywhere, therefore they
should not require custom browser.
• Application should be device agnostic.
Jari-Pekka Voutilainen 7
Browser application state
• Our previous studies:
• Largely focused on JavaScript variables
• Lively3D had pre-defined variables which were serialized
• Backend-as-a-Service projects which stored variables to cloud database
• HTML5 Mobile Agents allowed user defined variables which were serialized
with the agent.
Jari-Pekka Voutilainen 8
Browser application state
• JavaScript variables are not the only state in applications that is relevant.
• Most modern web applications store some of the state to the DOM tree.
• Dynamically created elements, styles and so on..
• Most modern JavaScript frameworks do this behind the scenes.
Jari-Pekka Voutilainen 9
Virtual DOM
• Popularized by React.js.
• Novel technology, multiple implementations.
• Abstract version of the DOM tree.
• Usually consists of the following algorithms:
• Creation
• Manipulation
• Comparison
• Applying to DOM tree
Jari-Pekka Voutilainen 10
Proof of Concept
• Our proof of concept focuses on the state synchronization.
• Requires minimal implementation from the developer.
• Main contribution is in the browser side
• Server side is minimal implementation to enable migration
• Could be implemented numerous ways, currently using WebSockets.
Jari-Pekka Voutilainen 11
Proof of concept
• Our Proof of Concept is based on the initial state of the application.
• Virtualized from DOM tree after the application has loaded.
• Can be used as a comparison point to whatever state the DOM tree has.
• Virtual DOM library used in the PoC, provides comparison algorithm which
creates a set of operations needed to execute for DOM tree to change from
a to b.
Jari-Pekka Voutilainen 12
State transfer
• Our PoC creates required set of operations to migrate from initial state to the
current state.
• Can not be migrated as such since JavaScript object prototypes are not
serialized.
• Some of the prototype information is stored with the object so that the
prototypes can be recreated in the next browser.
• Receiving browser applies the operations to its initial state and applies this to
the actual DOM.
• Application DOM is migrated from browser to browser.
Jari-Pekka Voutilainen 13
Issues
• Only data present in the DOM is migrated.
• Functions bound to the DOM elements are actually in JavaScript namespace
• Bindings are lost when DOM is migrated.
• To compensate PoC has means for developers to register functions and how
they are bound in DOM
• These are serialized and rebound after migration.
Jari-Pekka Voutilainen 14
Demos
• Example application: Todo list
• User can add items, mark them done and remove them
• All of the state of application is stored to the DOM for the sake of demo
• TODO app
Jari-Pekka Voutilainen 15
Minimal implementation
• To enable state migration, developer needs minimal implementation.
Jari-Pekka Voutilainen 16
State transfer
var Liquid = require(‘@zharktas/liquid.js');
var liquid = new Liquid();
Binding dynamic functions
• To transfer dynamic functions, developer needs to register the functions and
note them in the DOM
Jari-Pekka Voutilainen 17
Bound functions
var checkbox = document.createElement('input');
checkbox.addEventListener('click', someFunction);
checkbox.setAttribute('data-handler', 'toggleClick');
liquid.registerHandler('toggleClick', {'click': someFunction});
Examples online
• All code is available at Github and NPM
• https://github.com/Zharktas/Liquid-Todo
• https://github.com/Zharktas/liquid.js
• https://www.npmjs.com/package/@zharktas/liquid.js
Jari-Pekka Voutilainen 18
Questions ?
@zharktas
Jari-Pekka Voutilainen
+358 40 553 8558
jari.voutilainen@iki.fi

Mais conteúdo relacionado

Mais procurados

Mais procurados (7)

Blazor certification training - Dot Net Tricks
Blazor certification training - Dot Net TricksBlazor certification training - Dot Net Tricks
Blazor certification training - Dot Net Tricks
 
Documentum: where do we go from here
Documentum: where do we go from hereDocumentum: where do we go from here
Documentum: where do we go from here
 
Project archive what to do with those projects that have completed or place...
Project archive   what to do with those projects that have completed or place...Project archive   what to do with those projects that have completed or place...
Project archive what to do with those projects that have completed or place...
 
Project archive what to do with those projects that have completed or place...
Project archive   what to do with those projects that have completed or place...Project archive   what to do with those projects that have completed or place...
Project archive what to do with those projects that have completed or place...
 
Web flowpresentation
Web flowpresentationWeb flowpresentation
Web flowpresentation
 
MongoDB and Machine Learning with Flowable
MongoDB and Machine Learning with FlowableMongoDB and Machine Learning with Flowable
MongoDB and Machine Learning with Flowable
 
Share point saturday presentation 9 29-2012-2
Share point saturday presentation 9 29-2012-2Share point saturday presentation 9 29-2012-2
Share point saturday presentation 9 29-2012-2
 

Destaque

Destaque (20)

Repaint & reflow
Repaint & reflowRepaint & reflow
Repaint & reflow
 
Intro to Web Map APIs
Intro to Web Map APIsIntro to Web Map APIs
Intro to Web Map APIs
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to React
 
React entry
React entryReact entry
React entry
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to React
 
Digitaalisesti vaikuttavaksi. @HelsinkiUniUX -projektin tarina
Digitaalisesti vaikuttavaksi. @HelsinkiUniUX  -projektin tarina Digitaalisesti vaikuttavaksi. @HelsinkiUniUX  -projektin tarina
Digitaalisesti vaikuttavaksi. @HelsinkiUniUX -projektin tarina
 
Why and How to Use Virtual DOM
Why and How to Use Virtual DOMWhy and How to Use Virtual DOM
Why and How to Use Virtual DOM
 
React.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMReact.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOM
 
ReactNativeを語る勉強会
ReactNativeを語る勉強会ReactNativeを語る勉強会
ReactNativeを語る勉強会
 
Pjax 深入淺出
Pjax 深入淺出Pjax 深入淺出
Pjax 深入淺出
 
React
ReactReact
React
 
From Back to Front: Rails To React Family
From Back to Front: Rails To React FamilyFrom Back to Front: Rails To React Family
From Back to Front: Rails To React Family
 
React Native - Workshop
React Native - WorkshopReact Native - Workshop
React Native - Workshop
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
React.js in real world apps.
React.js in real world apps. React.js in real world apps.
React.js in real world apps.
 
[@NaukriEngineering] Git Basic Commands and Hacks
[@NaukriEngineering] Git Basic Commands and Hacks[@NaukriEngineering] Git Basic Commands and Hacks
[@NaukriEngineering] Git Basic Commands and Hacks
 
An Introduction to ReactJS
An Introduction to ReactJSAn Introduction to ReactJS
An Introduction to ReactJS
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
Intro to react native
Intro to react nativeIntro to react native
Intro to react native
 
React - render() to DOM - Boris Dinkevich - Codemotion Milan 2016
React - render() to DOM - Boris Dinkevich - Codemotion Milan 2016React - render() to DOM - Boris Dinkevich - Codemotion Milan 2016
React - render() to DOM - Boris Dinkevich - Codemotion Milan 2016
 

Semelhante a Synchronizing application state using Virtual DOM trees

Create a Windows 8 App in minutes
Create a Windows 8 App in minutesCreate a Windows 8 App in minutes
Create a Windows 8 App in minutes
Frank La Vigne
 
Datasheet weblogicpluginforrd
Datasheet weblogicpluginforrdDatasheet weblogicpluginforrd
Datasheet weblogicpluginforrd
MidVision
 

Semelhante a Synchronizing application state using Virtual DOM trees (20)

Meteor + React
Meteor + ReactMeteor + React
Meteor + React
 
React js
React jsReact js
React js
 
React + Mobile
React + MobileReact + Mobile
React + Mobile
 
AD114 -- Beyond the Mobile Browser? Building Rich Mobile Applications for IBM...
AD114 -- Beyond the Mobile Browser? Building Rich Mobile Applications for IBM...AD114 -- Beyond the Mobile Browser? Building Rich Mobile Applications for IBM...
AD114 -- Beyond the Mobile Browser? Building Rich Mobile Applications for IBM...
 
Meteor meetup
Meteor meetupMeteor meetup
Meteor meetup
 
Introduction to react native with redux
Introduction to react native with reduxIntroduction to react native with redux
Introduction to react native with redux
 
Fluxible
FluxibleFluxible
Fluxible
 
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud EnvironmentsTools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
 
Transforming to Microservices
Transforming to MicroservicesTransforming to Microservices
Transforming to Microservices
 
Progressive Web Apps
Progressive Web AppsProgressive Web Apps
Progressive Web Apps
 
Create a Windows 8 App in minutes
Create a Windows 8 App in minutesCreate a Windows 8 App in minutes
Create a Windows 8 App in minutes
 
Chapter 11:Understanding Client-Side Technologies
Chapter 11:Understanding Client-Side TechnologiesChapter 11:Understanding Client-Side Technologies
Chapter 11:Understanding Client-Side Technologies
 
Datasheet weblogicpluginforrd
Datasheet weblogicpluginforrdDatasheet weblogicpluginforrd
Datasheet weblogicpluginforrd
 
Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!
 
O365 Developer Bootcamp NJ 2018 - Material
O365 Developer Bootcamp NJ 2018 - MaterialO365 Developer Bootcamp NJ 2018 - Material
O365 Developer Bootcamp NJ 2018 - Material
 
Servlet programming
Servlet programmingServlet programming
Servlet programming
 
Angular Or React – Don’t Roll The Dice
Angular Or React – Don’t Roll The DiceAngular Or React – Don’t Roll The Dice
Angular Or React – Don’t Roll The Dice
 
Micro Frontends
Micro FrontendsMicro Frontends
Micro Frontends
 
Build 12-Factor apps with Docker
Build 12-Factor apps with DockerBuild 12-Factor apps with Docker
Build 12-Factor apps with Docker
 
ReactJS - Re-rendering pages in the age of the mutable DOM
ReactJS - Re-rendering pages in the age of the mutable DOMReactJS - Re-rendering pages in the age of the mutable DOM
ReactJS - Re-rendering pages in the age of the mutable DOM
 

Último

Seismic Method Estimate velocity from seismic data.pptx
Seismic Method Estimate velocity from seismic  data.pptxSeismic Method Estimate velocity from seismic  data.pptx
Seismic Method Estimate velocity from seismic data.pptx
AlMamun560346
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
Areesha Ahmad
 
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
ssuser79fe74
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Lokesh Kothari
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
gindu3009
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
PirithiRaju
 
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
Lokesh Kothari
 

Último (20)

Seismic Method Estimate velocity from seismic data.pptx
Seismic Method Estimate velocity from seismic  data.pptxSeismic Method Estimate velocity from seismic  data.pptx
Seismic Method Estimate velocity from seismic data.pptx
 
GBSN - Microbiology (Unit 3)
GBSN - Microbiology (Unit 3)GBSN - Microbiology (Unit 3)
GBSN - Microbiology (Unit 3)
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
 
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
 
Factory Acceptance Test( FAT).pptx .
Factory Acceptance Test( FAT).pptx       .Factory Acceptance Test( FAT).pptx       .
Factory Acceptance Test( FAT).pptx .
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)
 
Forensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfForensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdf
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
 
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Service
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts ServiceJustdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Service
Justdial Call Girls In Indirapuram, Ghaziabad, 8800357707 Escorts Service
 
CELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdfCELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdf
 
High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)
 
Clean In Place(CIP).pptx .
Clean In Place(CIP).pptx                 .Clean In Place(CIP).pptx                 .
Clean In Place(CIP).pptx .
 
Site Acceptance Test .
Site Acceptance Test                    .Site Acceptance Test                    .
Site Acceptance Test .
 
COST ESTIMATION FOR A RESEARCH PROJECT.pptx
COST ESTIMATION FOR A RESEARCH PROJECT.pptxCOST ESTIMATION FOR A RESEARCH PROJECT.pptx
COST ESTIMATION FOR A RESEARCH PROJECT.pptx
 
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)
 
SAMASTIPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
SAMASTIPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICESAMASTIPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICE
SAMASTIPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
 

Synchronizing application state using Virtual DOM trees

  • 1. © Gofore Oy 2016 • Synchronizing Application State Using Virtual DOM Trees Jari-Pekka Voutilainen, Tommi Mikkonen and Kari Systä Jari-Pekka Voutilainen
  • 2. Me • PHD student at Tampere University of Technology • Researched Browser applications since 2011 • Currently working at Gofore Ltd. • Finnish software consultation company • @zharktas in twitter • Jari.Voutilainen@iki.fi Jari-Pekka Voutilainen 2
  • 3. Agenda • Background • Liquid applications • Browser application state • Virtual DOM • Serializing browser state • Demos Jari-Pekka Voutilainen 3
  • 4. Background • Multiple devices • Applications need to be installed multiple times • Applications might be in different states • Applications require large scale backend for storing state • Transferring application between devices is not currently feasible. Jari-Pekka Voutilainen 4
  • 5. Liquid Applications • Defined as applications that can flow from device to device. • Three subsystems were identified: • User interface • Persistent data and content • State of the application Jari-Pekka Voutilainen 5
  • 6. Liquid applications • This study focuses on the state of the applications. • Multiple options for migrating browser application state: • Complete memory space of the browser • Pre-defined set of variables • Determining relevant state from the application Jari-Pekka Voutilainen 6
  • 7. Liquid Application Framework • The goal is to make developing liquid applications simple. • Developers had to implement specific APIs for application transfer. • Application should not be designed to be liquid. • Basis should be in existing browser implementations. • Liquid applications do not need to be installed everywhere, therefore they should not require custom browser. • Application should be device agnostic. Jari-Pekka Voutilainen 7
  • 8. Browser application state • Our previous studies: • Largely focused on JavaScript variables • Lively3D had pre-defined variables which were serialized • Backend-as-a-Service projects which stored variables to cloud database • HTML5 Mobile Agents allowed user defined variables which were serialized with the agent. Jari-Pekka Voutilainen 8
  • 9. Browser application state • JavaScript variables are not the only state in applications that is relevant. • Most modern web applications store some of the state to the DOM tree. • Dynamically created elements, styles and so on.. • Most modern JavaScript frameworks do this behind the scenes. Jari-Pekka Voutilainen 9
  • 10. Virtual DOM • Popularized by React.js. • Novel technology, multiple implementations. • Abstract version of the DOM tree. • Usually consists of the following algorithms: • Creation • Manipulation • Comparison • Applying to DOM tree Jari-Pekka Voutilainen 10
  • 11. Proof of Concept • Our proof of concept focuses on the state synchronization. • Requires minimal implementation from the developer. • Main contribution is in the browser side • Server side is minimal implementation to enable migration • Could be implemented numerous ways, currently using WebSockets. Jari-Pekka Voutilainen 11
  • 12. Proof of concept • Our Proof of Concept is based on the initial state of the application. • Virtualized from DOM tree after the application has loaded. • Can be used as a comparison point to whatever state the DOM tree has. • Virtual DOM library used in the PoC, provides comparison algorithm which creates a set of operations needed to execute for DOM tree to change from a to b. Jari-Pekka Voutilainen 12
  • 13. State transfer • Our PoC creates required set of operations to migrate from initial state to the current state. • Can not be migrated as such since JavaScript object prototypes are not serialized. • Some of the prototype information is stored with the object so that the prototypes can be recreated in the next browser. • Receiving browser applies the operations to its initial state and applies this to the actual DOM. • Application DOM is migrated from browser to browser. Jari-Pekka Voutilainen 13
  • 14. Issues • Only data present in the DOM is migrated. • Functions bound to the DOM elements are actually in JavaScript namespace • Bindings are lost when DOM is migrated. • To compensate PoC has means for developers to register functions and how they are bound in DOM • These are serialized and rebound after migration. Jari-Pekka Voutilainen 14
  • 15. Demos • Example application: Todo list • User can add items, mark them done and remove them • All of the state of application is stored to the DOM for the sake of demo • TODO app Jari-Pekka Voutilainen 15
  • 16. Minimal implementation • To enable state migration, developer needs minimal implementation. Jari-Pekka Voutilainen 16 State transfer var Liquid = require(‘@zharktas/liquid.js'); var liquid = new Liquid();
  • 17. Binding dynamic functions • To transfer dynamic functions, developer needs to register the functions and note them in the DOM Jari-Pekka Voutilainen 17 Bound functions var checkbox = document.createElement('input'); checkbox.addEventListener('click', someFunction); checkbox.setAttribute('data-handler', 'toggleClick'); liquid.registerHandler('toggleClick', {'click': someFunction});
  • 18. Examples online • All code is available at Github and NPM • https://github.com/Zharktas/Liquid-Todo • https://github.com/Zharktas/liquid.js • https://www.npmjs.com/package/@zharktas/liquid.js Jari-Pekka Voutilainen 18
  • 19. Questions ? @zharktas Jari-Pekka Voutilainen +358 40 553 8558 jari.voutilainen@iki.fi