SlideShare a Scribd company logo
Asynchrono
    us
Or, how to build a great web experience.
•Responsive
• Non blocking
• Realtime
Speed
 Is essential
Fred Wilson
10 golden rules for building successful web apps
Or



Perceived
  Speed
Holla
New name please?
Asynchronous Interfaces
Asynchronous Interfaces
Asynchronous Interfaces
Move logic
   and
rendering
Forget RJS
Options?
SproutCore
Cappuccino
Libraries,
 libraries,
everywhere
SuperClass
  SuperApp
 SuperModel
SuperConnect
  SuperRPC
SuperClass
Very simple class abstraction & inheritance
var SuperApp = new SuperClass;
SuperApp.include(SuperEvent);
SuperApp.include({
  init: function(name){
    this.name = name;
  }
});

var App = new SuperApp("name");

App.bind("load", function(){});

SuperApp.extend({
  // Class methods
})
SuperApp
SuperApp

•State Machine
• Global Events
• Modular
(function($){

var state = App.state.add("loading");

state.afterEnter(function(){
  App.log("Loaded state!")
});

state.setup(function(){
  App.log("Executed on first instantiation")
});

state.load(function(){
  App.log("Executed on page load")
});

})(jQuery);



App.state.change("loading")
SuperApp.Vi
   Simple view manager
App.state.view = new SuperApp.View($("#views"));
<div id="views">
  <div class="loading" data-view="loading">
    <h2>Loading...</h2>
  </div>

  <div class="channel" data-view="channel">
  ...
  </div>
</div>
SuperModel
    ORM
var Channel = SuperModel.setup("Channel");
Channel.attributes = ["name"];


var channel = new Channel;
channel.name = "Foo"
channel.save();
Preload data
    Instant access
class RiaController < ApplicationController
  before_filter :require_user
  respond_to :html, :json
  layout false

  def index
  end

  def loader
    @activity           =   current_user.activity
    @channel_activity   =   current_user.channel_activity
    @channels           =   current_user.channels
    @users              =   [current_user]

    render :json => {
        :activity            =>   @activity,
        :channel_activity    =>   @channel_activity,
        :channels            =>   @channels,
        :users               =>   @users
      }
  end
end
jQuery(function($){
  App.trigger("loading");

  var loader = function(data){
    for (var name in data) {
      var model = $.constantize($.classify(name));
      model.populate(data[name]);
    }

   App.state.change("loaded");
 };

  $.ajax({
    url: "/ria/loader",
    dataType: "json",
    cache: false,
    success: loader
  });
});
Asynchronous Interfaces
SuperConne
  Templating & binding
<div>
  <ul id="channels">
   <li>${name}</li>
  </ul>
</div>
var element   = $("#channels");
var connector = new SuperConnect(Channel, element);
Asynchronous Interfaces
SuperRPC
   JSON RPC
class RiaController < ApplicationController
  before_filter :require_user
  respond_to :html, :json

  include SuperRPC::Controller
end
class ChannelActivity < SuperModel::Base
  include SuperRPC::Model
end
SuperRPC.invoke(
 "ChannelActivity",
 "update",
 [1, {name: "New name"}]
);
user.saveRemote();
Sprockets
app
 javascripts
   application.js
   lib
   models
     channel.js
     user.js
   states
    channel.js
    search.js
gem "rack-sprockets"
gem "yui-compressor"




config.middleware.use "Rack::Sprockets",
  :load_path => ["app/javascripts/", "app/javascripts/lib/"]
//= require <jquery>

//= require <rails>
//= require <rails.application>
What else?
jquery.drop.j
this.view.dropArea();

this.view.bind("drop", this.proxy(function(e){
   e.stopPropagation();
   e.preventDefault();

  var files = e.originalEvent.dataTransfer.files;
  for ( var i = 0; i < files.length; i++)
       this.createAsset(files[i]);

   return false;
}));
FileReader
if (typeof FileReader != "undefined" &&
    file.type.match(/image.*/) &&
      file.size < 50000000) {

    var reader = new FileReader();
    reader.onload = function(e) {
       img.attr({src: e.target.result});
    };
    reader.readAsDataURL(file);
}
File Uploads
jquery.upload.j
$.upload(file, options);
One more thing...
Realtime
Juggernaut
4 Years Old
Juggernaut 2
What’s new?

• WebSocket support
• Built on Node.js
• Horizontally scalable
• PubSub model
• Even more simple!
<script src="http://localhost:8080/application.js" type="text/
javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
  jQuery(function($){
    var jug = new Juggernaut;
    jug.subscribe("/chats", function(data){
      // ETC
    });
  });
</script>
<script src="http://localhost:8080/application.js" type="text/
javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
  jQuery(function($){
    var jug = new Juggernaut;
    jug.subscribe("/chats", function(data){
      $("#chats").append($("<li />").text(data));
    });
  });
</script>
<script src="http://localhost:8080/application.js" type="text/
javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
  jQuery(function($){
    var jug = new Juggernaut;
    jug.subscribe("/chats/203942lkj34u0uasdf084", function(data){
      $("#chats").append($("<li />").text(data));
    });
  });
</script>
Juggernaut.publish("/chats","Hello World!")
Asynchronous Interfaces
Asynchronous Interfaces
http://github.com/
@maccman

More Related Content

PDF
Introduction to AngularJS For WordPress Developers
PDF
How to replace rails asset pipeline with webpack?
PPTX
Web apps without internet
PDF
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
PDF
Connecting Content Silos: One CMS, Many Sites With The WordPress REST API
PDF
Phinx talk
PDF
Caldera Learn - LoopConf WP API + Angular FTW Workshop
PDF
Bootstrat REST APIs with Laravel 5
Introduction to AngularJS For WordPress Developers
How to replace rails asset pipeline with webpack?
Web apps without internet
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Connecting Content Silos: One CMS, Many Sites With The WordPress REST API
Phinx talk
Caldera Learn - LoopConf WP API + Angular FTW Workshop
Bootstrat REST APIs with Laravel 5

What's hot (20)

PDF
Extending the WordPress REST API - Josh Pollock
PPTX
An introduction to Laravel Passport
PDF
Using the new WordPress REST API
PPT
JavaScript JQUERY AJAX
PDF
Spout - Building a RESTful web app with Angular.js and BEAR.Sunday
PDF
AnkaraJUG Kasım 2012 - PrimeFaces
PDF
JSF 2.0 Preview
PDF
The Open Web and what it means
PDF
JavaScript APIs - The Web is the Platform
PPTX
Building a dashboard using AngularJS
KEY
Offline Application Cache
PDF
Service worker - Offline Web
PDF
URLProtocol
PDF
JQuery UK Service Workers Talk
PDF
JQuery UK February 2015: Service Workers On Vacay
PDF
Service worker API
PDF
Second Level Cache in JPA Explained
PPTX
REST APIs in Laravel 101
ODP
Running ms sql stored procedures in mule
Extending the WordPress REST API - Josh Pollock
An introduction to Laravel Passport
Using the new WordPress REST API
JavaScript JQUERY AJAX
Spout - Building a RESTful web app with Angular.js and BEAR.Sunday
AnkaraJUG Kasım 2012 - PrimeFaces
JSF 2.0 Preview
The Open Web and what it means
JavaScript APIs - The Web is the Platform
Building a dashboard using AngularJS
Offline Application Cache
Service worker - Offline Web
URLProtocol
JQuery UK Service Workers Talk
JQuery UK February 2015: Service Workers On Vacay
Service worker API
Second Level Cache in JPA Explained
REST APIs in Laravel 101
Running ms sql stored procedures in mule
Ad

Viewers also liked (9)

PDF
An introduction to online qualitative research
PPT
Robert Drobish - 1Velocity Network Compliance Lunch
PPTX
7 Ways to Build a Family Tree Using Social Media
PDF
서바이벌 나는 개발자다
PPT
Building Community 101
PDF
Social Media Best Practices for the Airline Industry
PPTX
Challenges of Building a Global Community
PDF
An introduction to customer panels
PDF
사용자 경험(UX) 기반의 제품과 서비스
An introduction to online qualitative research
Robert Drobish - 1Velocity Network Compliance Lunch
7 Ways to Build a Family Tree Using Social Media
서바이벌 나는 개발자다
Building Community 101
Social Media Best Practices for the Airline Industry
Challenges of Building a Global Community
An introduction to customer panels
사용자 경험(UX) 기반의 제품과 서비스
Ad

Similar to Asynchronous Interfaces (20)

PDF
SproutCore and the Future of Web Apps
PPTX
Pengenalan blaast platform sdk
PDF
Building Smart Async Functions For Mobile
PPTX
Where is my scalable api?
KEY
Service Oriented Applications
PDF
How to disassemble one monster app into an ecosystem of 30
PPTX
Where is my scalable API?
PDF
Ruby on Rails - Introduction
PDF
TorqueBox
PDF
Real Time Web - What's that for?
PDF
An approach to responsive, realtime with Backbone.js and WebSockets
KEY
Modular Web Applications With Netzke
PDF
RubyConf Taiwan 2016 - Large scale Rails applications
PDF
RoR 101: Session 3
PPTX
From Ruby to Node.js
KEY
Javascript Frameworks for Well Architected, Immersive Web Apps
PPT
Ruby on Rails industry trends
PDF
Yii2 guide
PDF
Flexiblerails
DOCX
RabbitMQ in Microservice Architecture.docx
SproutCore and the Future of Web Apps
Pengenalan blaast platform sdk
Building Smart Async Functions For Mobile
Where is my scalable api?
Service Oriented Applications
How to disassemble one monster app into an ecosystem of 30
Where is my scalable API?
Ruby on Rails - Introduction
TorqueBox
Real Time Web - What's that for?
An approach to responsive, realtime with Backbone.js and WebSockets
Modular Web Applications With Netzke
RubyConf Taiwan 2016 - Large scale Rails applications
RoR 101: Session 3
From Ruby to Node.js
Javascript Frameworks for Well Architected, Immersive Web Apps
Ruby on Rails industry trends
Yii2 guide
Flexiblerails
RabbitMQ in Microservice Architecture.docx

Asynchronous Interfaces

Editor's Notes

  • #2: Lot of JavaScript in this talk! Should really be speaking at LJUG.
  • #4: Google going to add it to pagerank.
  • #7: Group chat app. For developers. iPad.
  • #9: using MacRuby/WebKit
  • #10: What&amp;#x2019;s great is this interface is realtime - synced between all clients. Even the file upload progress bar are synced - everybody can see when a file is being uploaded.
  • #11: You client should be able to function without a server.
  • #12: Just learn JavaScript - it&amp;#x2019;s too important for you not too.
  • #14: Don&amp;#x2019;t like any framework that abstracts away from the DOM. Want something like light, lik JQuery, componentized and flexible.
  • #15: Rather than give you a high level I&amp;#x2019;m going to be as practical as possible, and go through various libraries I&amp;#x2019;ve built
  • #27: Facebook search. Needs to be accessed locally so your UI is instantaneous.
  • #39: Pass a function as the last argument to get a callback.
  • #40: We&amp;#x2019;ve added class support to JavaScript, now we need to add &amp;#x2018;require&amp;#x2019; support.
  • #46: If you want to add other variables to the page, such as a user-id, such is the way to do it.
  • #47: So, now that I&amp;#x2019;ve explained the various libraries and techniques I use, I want to tackle one of the major UI flaws - file uploading. Tangent.
  • #48: HTML5 lets you drag and drop files to upload them
  • #49: But the API requires you to implement at least 5 methods to get it work
  • #50: http://www.quirksmode.org/blog/archives/2009/09/the_html5_drag.html
  • #56: Webkit lets you upload files by pasting them too.
  • #61: No request/response model
  • #63: Created when I was 16
  • #67: Group chat
  • #68: Single user chat
  • #69: One of the few pieces of Ruby in this talk Juggernaut Ruby client
  • #72: Just add a class observer
  • #74: Looking for consultancy