27
Why would a programmer fall in love with SPA? Creating Single Page Applications with Rails && Ember.js Created by / from Maria Stokłosa @mariastoklosa netguru.co

Why Would A Programmer Fall In Love With SPA?

  • Upload
    netguru

  • View
    781

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Why Would A Programmer Fall In Love With SPA?

Why would a programmerfall in love with SPA?

Creating Single Page Applications with Rails && Ember.jsCreated by / from Maria Stokłosa @mariastoklosa netguru.co

Page 2: Why Would A Programmer Fall In Love With SPA?

Idea of Single PageApplications

Single Page Applications allow to redraw any part of thewebsite without additional server requests to get the HTML

code.

Page 3: Why Would A Programmer Fall In Love With SPA?

Traditional page lifecycleCLIENT creates an initial request

Page 4: Why Would A Programmer Fall In Love With SPA?

Traditional page lifecycleSERVER responds with HTML code

Page 5: Why Would A Programmer Fall In Love With SPA?

Traditional page lifecycleCLIENT creates HTTP request

Page 6: Why Would A Programmer Fall In Love With SPA?

Traditional page lifecycleSERVER responds with HTML code

Page 7: Why Would A Programmer Fall In Love With SPA?

Traditional page lifecycleWebsite reloads

Page 8: Why Would A Programmer Fall In Love With SPA?

SPA page lifecycleCLIENT creates an initial request

Page 9: Why Would A Programmer Fall In Love With SPA?

SPA page lifecycleSERVER responds with HTML code

Page 10: Why Would A Programmer Fall In Love With SPA?

SPA page lifecycleCLIENT creates an AJAX request

Page 11: Why Would A Programmer Fall In Love With SPA?

SPA page lifecycleSERVER responds with JSON

Page 12: Why Would A Programmer Fall In Love With SPA?

SPA page lifecycleWebsite does not reload! :))))))

Page 13: Why Would A Programmer Fall In Love With SPA?

SPA websites - prosBetter from the UX point of view

Mobile preferred

Provide separation of client and server responsibilities

Complete control of the loading experience because ofAJAX calls

Page 14: Why Would A Programmer Fall In Love With SPA?

SPA websites - consClient has to have JavaScript enabled

Good SPA apps are hard to develop

Unnatural URLs (fragment identifiers)

Indexing a website may be complicated

Page 15: Why Would A Programmer Fall In Love With SPA?

How to create a SPAapplication?

Ember.js

AngularJS

Meteor

Backbone.js

Page 16: Why Would A Programmer Fall In Love With SPA?

How to choose a properframework?

Routing

Templating

Testability

Browser compatibility

API integrations

Page 17: Why Would A Programmer Fall In Love With SPA?

Why Ember.js?Ember is now fast (isemberfastyet.com)

Using MVC framework has many benefits

Getting 15 jQuery plugins to work together might beproblematic

Binding templates to variables is cool

Page 18: Why Would A Programmer Fall In Love With SPA?

Is Ember.js better thanAngularJS?

NO

Page 19: Why Would A Programmer Fall In Love With SPA?

Creating SPA websiteswon't fix your poor

UX/design problems

Page 20: Why Would A Programmer Fall In Love With SPA?

Ways to use Ember withRails

2 separate applications

Ember.js embedded in Rails application

Page 21: Why Would A Programmer Fall In Love With SPA?

How to start?Include in your Gemfile && run bundle install

gem 'ember-cli-rails'

Page 22: Why Would A Programmer Fall In Love With SPA?

Use generator to guide yourails generate ember-cli:init

Page 23: Why Would A Programmer Fall In Love With SPA?

Hook ember app to yourpage

EmberCLI.configure do |config| config.app :enrollment, path: 'app/ember/frontend' config.app :admin #=> path will be app/adminend

= include_ember_script_tags :enrollment

Page 24: Why Would A Programmer Fall In Love With SPA?

Mount EmberCLI testengine in config/routes.rbmount EmberCLI::Engine => "ember-tests", if: -> { Rails.env.development? }

Page 25: Why Would A Programmer Fall In Love With SPA?

Add root element toconfig/environment.js

APP: { rootElement: '.enrollment'}

Page 26: Why Would A Programmer Fall In Love With SPA?

Create a rake task forrunning ember tests

task default: 'ember:test'

Page 27: Why Would A Programmer Fall In Love With SPA?

THE END - Q & A- -

Ember.js documentationEmber-cli-rails