SlideShare une entreprise Scribd logo
1  sur  57
Dummies
       ne.js      for
Backb o               backbon e wi t h
        uction to use
I ntrod           s 3.1.x
              Rail
Everybody
needs an intro
course, Right?
3 Reasons to Use a
Front End Framework?
1. It Makes Your Front-
   End Code Testable
2. It Makes Your Front-
   End Code Testable
3. It Makes Your Front-
   End Code Testable
Jasmine.js
Other Benefits
•   Responsive UI with Event-Driven Communication

•   Maintainable Client Side Code by Convention

•   Easy Client-Server Syncing (RESTful)

•   Easy to integrate Web-Socket Technology

•   Works very well together with the Rails Asset
    Pipeline
The Rails Way
• Have you ever felt limited by Rail’s way to
  structure your App around resources and
  the RESTful actions. Do you design your
  Rails app in such a way (scaffoldish) that its
  easy and cheap to develop?
• Would you like to do what-ever you want
  on the front-end, but still use a restful, well
  structured, testable back-end?
Example App
Demo:
Have a look at the App
http://documentcloud.github.com/backbone/
Learning Backbone.js
This presentation is not a course, there are many
catches, do some good training, it will help you.

    •   Sources:

        •   Peepcode.com has 3 very good screencasts.
            http://peepcode.com/products/backbone-js

        •   Thoughtbot has a very good book:
            https://workshops.thoughtbot.com/
            backbone-js-on-rails
Cookbook
• Rails 3.1.3
• Backbone.js
• JQuery
• Pusher
• EJS Templates
• Backbone Forms
Backbone.js

• Model,View, Router
• Lightweight (< 700 lines)
• No UI Widgets - Write your own html,
  erb, haml, css, scss, sass
• Template Agnostic, bring your own
Use
www.coffeescript.org
Use a Push Technology

• Faye - http://faye.jcoglan.com/
• Event Machine - http://
  rubyeventmachine.com/
• Pusher
www.pusher.com
Pusher
•   It’s a complete abstraction of Push Technology in a SAAS
    approach

•   How does it work?

    •   Backend App send posts to Pusher server (Pusher
        GEM)

    •   Front-End uses Javascript to receive the events

    •   Channel based

    •   Uses web-sockets and falls back to Flash
jquery / zepto and
           Backbone.js
•   JQuery / Zepty: mark-up oriented

•   Backbone.js:

    •   Data Oriented
        Manipulate data and views are updated
        automatically.

    •   Single Page Application. Router ensures that
        the correct data is shown.

•   You need Both!
Templates

• .jst Templates (ejs) - http://embeddedjs.com
• The templates are rendered and then
  enriched with data by JQuery or Zepto
• Backbone-Forms - https://github.com/
  powmedia/backbone-forms
Example App: Shopping
      List App
Application Structure
• Details are free to chose - here a proposal
  is given - some people organise differently
• All Front End Code goes into
 • app/assets/javascripts
 • lib/assets/javascripts
 • vendor/assets/javascripts
Application Structure
            Collections

              Models
             Routers

              App

              Views
RSpec - Jasmine
  Structure
App
Not part of Backbone as such...
Used to have a namespace in JavaScript and
to avoid the information hiding problems of
JavaScript
App Specs
App Implementation
Models
Basic data structure used to capture behavior
of single instances. Instance methods,
abstraction sever interaction: save, destroy.
Model Spec
Models
Usage of Models
Collections
Data stucture to manage sets of instances.
Methods for filtering, sorting, abstraction of
server interaction: fetch.
Fixtures
Collection Specs
Collection
Views

• Used to view and interact with data
 • More comparable with a Rails controller
    than a Rails view.
 • Binds to Models and Collections to re-
    render itself when required.
Views, subviews
               ShoppingItemItem




     ShoppingItemsIndex
Templates
Templates
Combined Approach
View Specs
View
https://github.com/powmedia/backbone-forms

      Backbone Forms
One of the many form options.
Specify a schema in the model and generate a
shema from that model.
Use “commit” to save the form changes in your
model.
Save the model to the server.
Backbone Forms
Router
• Used to structure the various pages of
  your application.
• Translates URLs into the rendering of the
  correct views.
• Updates the browser URL and history.
• Option to use “#” or “/” as URL delimiter.
Router
Test
Kind of Tests?
•   Rails                     •   Backbone.js

    •   Acceptance Tests:         •   App Specs
        Capybara, Rspec
        Request, Cucumber
        with Selenium & Co.
                                  •   Helper Specs

                                  •   Models &
    •   Model Tests (rspec,           Collections Specs
        test Unit, ...)
                                  •   Router & Views
                                      Specs
Sync Adaptations
•   csrf:
    You need a
    BackboneRailsAuthTokenAdapter.
    I use the one of Thoughtbot.

•   Pusher
    You need to adapt the sync method to respond on
    incomming web-socket connections.
    I use the BackPusher, but there some bugs in it
    that you need to repair (due to newer backbone
    version) to pass the web-socket-id as a parameter.
Putting in Place Pusher


• Push State via Controler Adaptations
• Use BackPusher
Pusher - Rails Initializers
Pusher - Rails Controller
Pusher In App
Thank You

Contenu connexe

Tendances

FITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive ImagesFITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive ImagesRami Sayar
 
React.js for Rails Developers
React.js for Rails DevelopersReact.js for Rails Developers
React.js for Rails DevelopersArkency
 
Spring Boot. Boot up your development
Spring Boot. Boot up your developmentSpring Boot. Boot up your development
Spring Boot. Boot up your developmentStrannik_2013
 
React on rails v6.1 at LA Ruby, November 2016
React on rails v6.1 at LA Ruby, November 2016React on rails v6.1 at LA Ruby, November 2016
React on rails v6.1 at LA Ruby, November 2016Justin Gordon
 
Namespace less engine
Namespace less engineNamespace less engine
Namespace less engineshaokun
 
Angular.JS: Do it right
Angular.JS: Do it rightAngular.JS: Do it right
Angular.JS: Do it rightEugene Zharkov
 
Rails 3.1 Asset pipeline
Rails 3.1 Asset pipelineRails 3.1 Asset pipeline
Rails 3.1 Asset pipelinejeremyolliver
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on RailsAlessandro DS
 
Creating ambitious web application with Ember.js
Creating ambitious web application with Ember.jsCreating ambitious web application with Ember.js
Creating ambitious web application with Ember.jsTam Le
 
RESTful Api practices Rails 3
RESTful Api practices Rails 3RESTful Api practices Rails 3
RESTful Api practices Rails 3Anton Narusberg
 
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesKeep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesJer Clarke
 
Production ember getting started
Production ember getting startedProduction ember getting started
Production ember getting startedknomedia
 
Real World Rails Deployment
Real World Rails DeploymentReal World Rails Deployment
Real World Rails DeploymentAlan Hecht
 
Session iv(master pages)
Session iv(master pages)Session iv(master pages)
Session iv(master pages)Shrijan Tiwari
 
Ruby w/o Rails (Олександр Сімонов)
Ruby w/o Rails (Олександр Сімонов)Ruby w/o Rails (Олександр Сімонов)
Ruby w/o Rails (Олександр Сімонов)Fwdays
 

Tendances (20)

Rails engines
Rails enginesRails engines
Rails engines
 
FITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive ImagesFITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive Images
 
React.js for Rails Developers
React.js for Rails DevelopersReact.js for Rails Developers
React.js for Rails Developers
 
Spring Boot. Boot up your development
Spring Boot. Boot up your developmentSpring Boot. Boot up your development
Spring Boot. Boot up your development
 
React on rails v6.1 at LA Ruby, November 2016
React on rails v6.1 at LA Ruby, November 2016React on rails v6.1 at LA Ruby, November 2016
React on rails v6.1 at LA Ruby, November 2016
 
Spring.new hope.1.3
Spring.new hope.1.3Spring.new hope.1.3
Spring.new hope.1.3
 
Namespace less engine
Namespace less engineNamespace less engine
Namespace less engine
 
Angular.JS: Do it right
Angular.JS: Do it rightAngular.JS: Do it right
Angular.JS: Do it right
 
Rails 3.1 Asset pipeline
Rails 3.1 Asset pipelineRails 3.1 Asset pipeline
Rails 3.1 Asset pipeline
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Creating ambitious web application with Ember.js
Creating ambitious web application with Ember.jsCreating ambitious web application with Ember.js
Creating ambitious web application with Ember.js
 
RESTful Api practices Rails 3
RESTful Api practices Rails 3RESTful Api practices Rails 3
RESTful Api practices Rails 3
 
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesKeep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
 
Production ember getting started
Production ember getting startedProduction ember getting started
Production ember getting started
 
React on rails v4
React on rails v4React on rails v4
React on rails v4
 
Rails Engines
Rails EnginesRails Engines
Rails Engines
 
Real World Rails Deployment
Real World Rails DeploymentReal World Rails Deployment
Real World Rails Deployment
 
JavaScript MVC Frameworks: Backbone, Ember and Angular JS
JavaScript MVC Frameworks: Backbone, Ember and Angular JSJavaScript MVC Frameworks: Backbone, Ember and Angular JS
JavaScript MVC Frameworks: Backbone, Ember and Angular JS
 
Session iv(master pages)
Session iv(master pages)Session iv(master pages)
Session iv(master pages)
 
Ruby w/o Rails (Олександр Сімонов)
Ruby w/o Rails (Олександр Сімонов)Ruby w/o Rails (Олександр Сімонов)
Ruby w/o Rails (Олександр Сімонов)
 

En vedette (8)

Adiquity Publisher
Adiquity PublisherAdiquity Publisher
Adiquity Publisher
 
Adiquity Premium Offering
Adiquity Premium OfferingAdiquity Premium Offering
Adiquity Premium Offering
 
123團購網 new
123團購網 new123團購網 new
123團購網 new
 
Prototipo
PrototipoPrototipo
Prototipo
 
King louis xvi
King louis xviKing louis xvi
King louis xvi
 
Prototipo Pantalla Touch
Prototipo Pantalla TouchPrototipo Pantalla Touch
Prototipo Pantalla Touch
 
MI
MIMI
MI
 
Photo album 1
Photo album 1Photo album 1
Photo album 1
 

Similaire à Backbonification for dummies - Arrrrug 10/1/2012

Frameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic ReviewFrameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic Reviewnetc2012
 
Introduction to Ember.js and how we used it at FlowPro.io
Introduction to Ember.js and how we used it at FlowPro.ioIntroduction to Ember.js and how we used it at FlowPro.io
Introduction to Ember.js and how we used it at FlowPro.ioPaul Knittel
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8Thomas Robbins
 
Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...Lucas Jellema
 
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!Jeremy Likness
 
PLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfPLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfAlfresco Software
 
Ember App Kit & The Ember Resolver
Ember App Kit & The Ember ResolverEmber App Kit & The Ember Resolver
Ember App Kit & The Ember Resolvertboyt
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples Yochay Kiriaty
 
Targeting Mobile Platform with MVC 4.0
Targeting Mobile Platform with MVC 4.0Targeting Mobile Platform with MVC 4.0
Targeting Mobile Platform with MVC 4.0Mayank Srivastava
 
Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts weili_at_slideshare
 
Isomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the webIsomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the webSigma Software
 
Backbone JS for mobile apps
Backbone JS for mobile appsBackbone JS for mobile apps
Backbone JS for mobile appsIvano Malavolta
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Thomas Robbins
 
AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)Igor Talevski
 

Similaire à Backbonification for dummies - Arrrrug 10/1/2012 (20)

Frameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic ReviewFrameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic Review
 
Introduction to Ember.js and how we used it at FlowPro.io
Introduction to Ember.js and how we used it at FlowPro.ioIntroduction to Ember.js and how we used it at FlowPro.io
Introduction to Ember.js and how we used it at FlowPro.io
 
Building SPA’s (Single Page App) with Backbone.js
Building SPA’s (Single Page App) with Backbone.jsBuilding SPA’s (Single Page App) with Backbone.js
Building SPA’s (Single Page App) with Backbone.js
 
Show Some Spine!
Show Some Spine!Show Some Spine!
Show Some Spine!
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8
 
Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...Introduction to web application development with Vue (for absolute beginners)...
Introduction to web application development with Vue (for absolute beginners)...
 
Remix
RemixRemix
Remix
 
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!
 
PLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfPLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring Surf
 
Ember App Kit & The Ember Resolver
Ember App Kit & The Ember ResolverEmber App Kit & The Ember Resolver
Ember App Kit & The Ember Resolver
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
 
Targeting Mobile Platform with MVC 4.0
Targeting Mobile Platform with MVC 4.0Targeting Mobile Platform with MVC 4.0
Targeting Mobile Platform with MVC 4.0
 
Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts
 
Isomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the webIsomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the web
 
[2015/2016] Backbone JS
[2015/2016] Backbone JS[2015/2016] Backbone JS
[2015/2016] Backbone JS
 
Backbone JS for mobile apps
Backbone JS for mobile appsBackbone JS for mobile apps
Backbone JS for mobile apps
 
Sug bangalore - headless jss
Sug bangalore - headless jssSug bangalore - headless jss
Sug bangalore - headless jss
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)AngularJS 1.x - your first application (problems and solutions)
AngularJS 1.x - your first application (problems and solutions)
 

Dernier

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 

Dernier (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

Backbonification for dummies - Arrrrug 10/1/2012

  • 1. Dummies ne.js for Backb o backbon e wi t h uction to use I ntrod s 3.1.x Rail
  • 3. 3 Reasons to Use a Front End Framework?
  • 4. 1. It Makes Your Front- End Code Testable
  • 5. 2. It Makes Your Front- End Code Testable
  • 6. 3. It Makes Your Front- End Code Testable
  • 8. Other Benefits • Responsive UI with Event-Driven Communication • Maintainable Client Side Code by Convention • Easy Client-Server Syncing (RESTful) • Easy to integrate Web-Socket Technology • Works very well together with the Rails Asset Pipeline
  • 9. The Rails Way • Have you ever felt limited by Rail’s way to structure your App around resources and the RESTful actions. Do you design your Rails app in such a way (scaffoldish) that its easy and cheap to develop? • Would you like to do what-ever you want on the front-end, but still use a restful, well structured, testable back-end?
  • 11. Demo: Have a look at the App
  • 13. Learning Backbone.js This presentation is not a course, there are many catches, do some good training, it will help you. • Sources: • Peepcode.com has 3 very good screencasts. http://peepcode.com/products/backbone-js • Thoughtbot has a very good book: https://workshops.thoughtbot.com/ backbone-js-on-rails
  • 14. Cookbook • Rails 3.1.3 • Backbone.js • JQuery • Pusher • EJS Templates • Backbone Forms
  • 15. Backbone.js • Model,View, Router • Lightweight (< 700 lines) • No UI Widgets - Write your own html, erb, haml, css, scss, sass • Template Agnostic, bring your own
  • 16. Use
  • 18. Use a Push Technology • Faye - http://faye.jcoglan.com/ • Event Machine - http:// rubyeventmachine.com/ • Pusher
  • 20. Pusher • It’s a complete abstraction of Push Technology in a SAAS approach • How does it work? • Backend App send posts to Pusher server (Pusher GEM) • Front-End uses Javascript to receive the events • Channel based • Uses web-sockets and falls back to Flash
  • 21. jquery / zepto and Backbone.js • JQuery / Zepty: mark-up oriented • Backbone.js: • Data Oriented Manipulate data and views are updated automatically. • Single Page Application. Router ensures that the correct data is shown. • You need Both!
  • 22. Templates • .jst Templates (ejs) - http://embeddedjs.com • The templates are rendered and then enriched with data by JQuery or Zepto • Backbone-Forms - https://github.com/ powmedia/backbone-forms
  • 24. Application Structure • Details are free to chose - here a proposal is given - some people organise differently • All Front End Code goes into • app/assets/javascripts • lib/assets/javascripts • vendor/assets/javascripts
  • 25. Application Structure Collections Models Routers App Views
  • 26. RSpec - Jasmine Structure
  • 27. App Not part of Backbone as such... Used to have a namespace in JavaScript and to avoid the information hiding problems of JavaScript
  • 30. Models Basic data structure used to capture behavior of single instances. Instance methods, abstraction sever interaction: save, destroy.
  • 34. Collections Data stucture to manage sets of instances. Methods for filtering, sorting, abstraction of server interaction: fetch.
  • 38. Views • Used to view and interact with data • More comparable with a Rails controller than a Rails view. • Binds to Models and Collections to re- render itself when required.
  • 39. Views, subviews ShoppingItemItem ShoppingItemsIndex
  • 44. View
  • 45. https://github.com/powmedia/backbone-forms Backbone Forms One of the many form options. Specify a schema in the model and generate a shema from that model. Use “commit” to save the form changes in your model. Save the model to the server.
  • 46.
  • 48. Router • Used to structure the various pages of your application. • Translates URLs into the rendering of the correct views. • Updates the browser URL and history. • Option to use “#” or “/” as URL delimiter.
  • 50. Test
  • 51. Kind of Tests? • Rails • Backbone.js • Acceptance Tests: • App Specs Capybara, Rspec Request, Cucumber with Selenium & Co. • Helper Specs • Models & • Model Tests (rspec, Collections Specs test Unit, ...) • Router & Views Specs
  • 52. Sync Adaptations • csrf: You need a BackboneRailsAuthTokenAdapter. I use the one of Thoughtbot. • Pusher You need to adapt the sync method to respond on incomming web-socket connections. I use the BackPusher, but there some bugs in it that you need to repair (due to newer backbone version) to pass the web-socket-id as a parameter.
  • 53. Putting in Place Pusher • Push State via Controler Adaptations • Use BackPusher
  • 54. Pusher - Rails Initializers
  • 55. Pusher - Rails Controller

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n