SlideShare uma empresa Scribd logo
1 de 173
Y! Local mobile case study
    Gonzalo Cordero
       @goonieiam
AGENDA


• Intro, demo   & design principles

• Deconstruction    of a hybrid application

• Conclusion
VS
WHEN TO USE NATIVE
WHEN TO USE NATIVE

• Anything   that needs to access the device’s hardware
WHEN TO USE NATIVE

• Anything   that needs to access the device’s hardware

• You   can put it on the app store
WHEN TO USE NATIVE

• Anything       that needs to access the device’s hardware

• You   can put it on the app store

• That’s   it*
WHEN TO USE NATIVE

 • Anything       that needs to access the device’s hardware

 • You   can put it on the app store

 • That’s   it*




*We’ll cover a few gotchas later in the presentation
FOR EVERYTHING ELSE
FOR EVERYTHING ELSE
• You   are familiar with the technologies
FOR EVERYTHING ELSE
• You   are familiar with the technologies

• Write   once and use everywhere
FOR EVERYTHING ELSE
• You   are familiar with the technologies

• Write   once and use everywhere

• You   decide when/how to update
Hybrid - Best of both
       worlds?
*NATIVE


We ended up using it more than we
            wanted
WHY?
WHY?


• Paying   that beginners price?
WHY?


• Paying   that beginners price?

• Some “web” features    not reliable enough
WHY?


• Paying   that beginners price?

• Some “web” features    not reliable enough

• Some “web” features    were not available at the time
NATIVE*
NATIVE*

Geo
NATIVE*

       Geo


Navigation Controls
NATIVE*

       Geo


Navigation Controls



     Storage
WEB
WEB

All content
WEB

  All content




All interactions
YUI3 MOBILE EXAMPLE
YUI3 MOBILE EXAMPLE
pulldown event
YUI3 MOBILE EXAMPLE
pulldown event   ScrollView module
YUI3 MOBILE EXAMPLE
pulldown event   ScrollView module   touch-events + CSS3
TECHNOLOGIES
TECHNOLOGIES
TECHNOLOGIES
TECHNOLOGIES
TECHNOLOGIES
TECHNOLOGIES



               ????
“There is no mobile web,
just the web” - Stephen Hay
YUI().USE(“ALL”)
      “Use”
One           statement to rule them all
YUI.USE(“...”)
YUI.USE(“...”)


Loader
YUI.USE(“...”)


Loader
Events
YUI.USE(“...”)


    Loader
     Events
Y.Lang.Substitute
YUI.USE(“...”)


    Loader             Transitions

     Events
Y.Lang.Substitute
YUI.USE(“...”)


    Loader              Transitions

     Events           App Framework

Y.Lang.Substitute
1. Load & Delivery
App delivery through
      app store
Pack light or pack
   for a month?
WHAT TO PACK, WHAT TO
            PACK


• Base   core files(including YUI)

• Anything   that doesn’t change frequently or is static
Load the data pieces
      on demand
YUI().USE(“LOADER”)
YUI().USE(“LOADER”)
   Feature based loading
YUI().USE(“LOADER”)
   Feature based loading


   Dependency calculation
YUI().USE(“LOADER”)
   Feature based loading


   Dependency calculation


   On demand loading
YUI().USE(“LOADER”)
   Feature based loading


   Dependency calculation


   On demand loading


   Manual or Automatic
CACHING THE ASSETS


• We  cached all the assets once we downloaded the
 first time

• Using   native storage
How about HTML5
   Manifest?
Probably but...
HTML5 MANIFEST
HTML5 MANIFEST

• At
   the time we saw some inconsistencies with
 how the data persisted in memory
HTML5 MANIFEST

• At
   the time we saw some inconsistencies with
 how the data persisted in memory

• Flushing   the cache wasn’t reliable either
CACHING THE DATA
CACHING THE DATA


      JSON
CACHING THE DATA


       JSON

  Y.Lang.Substitute
CACHING THE DATA


       JSON

  Y.Lang.Substitute
2. Navigating around
NAVIGATION CONTROLS
NAVIGATION CONTROLS


• All   the navigation is done natively
NAVIGATION CONTROLS


• All   the navigation is done natively

• Logic   & visual aspects not available at the time
NAVIGATION CONTROLS


• All   the navigation is done natively

• Logic   & visual aspects not available at the time

• Some     major drawbacks
NAVIGATION
NAVIGATION

      position: fixed wasn’t
       working properly
           at the time.
NAVIGATION

        position: fixed wasn’t
         working properly
             at the time.




     Navigation logic was easier
       to implement natively
NATIVE NAVIGATION
NATIVE NAVIGATION
1. Load the view
NATIVE NAVIGATION
1. Load the view
NATIVE NAVIGATION
1. Load the view
NATIVE NAVIGATION
1. Load the view

2. While loading, disable
navigation controls
NATIVE NAVIGATION
1. Load the view

2. While loading, disable
navigation controls
NATIVE NAVIGATION
1. Load the view

2. While loading, disable
navigation controls
3. Send articles information
to native
NATIVE NAVIGATION
1. Load the view

2. While loading, disable
navigation controls
3. Send articles information
to native
NATIVE NAVIGATION
NATIVE NAVIGATION


• Loading   more data than we needed
NATIVE NAVIGATION


• Loading   more data than we needed

• Race   conditions
NATIVE NAVIGATION


• Loading   more data than we needed

• Race   conditions

• Several   bridge calls
If I were to build it
      today...
A BETTER SOLUTION

Transitions   App Framework
YUI().USE(“APP”)
            route
YUI().USE(“APP”)
              route




       Home
YUI().USE(“APP”)
              route




              Saved
       Home
              Items
YUI().USE(“APP”)
              route




              Saved
       Home           Settings
              Items
YUI().USE(“TRANSITION”)
YUI().USE(“TRANSITION”)
YUI().USE(“TRANSITION”)

Y.one('#homeView').transition({
    width: {
        duration: 0.5,
        easing: 'ease-out',
        value: 0
    }
}, function() {
    showNextView();
});
YUI().USE(“TRANSITION”)

Y.one('#homeView').transition({
    width: {
        duration: 0.5,
        easing: 'ease-out',
        value: 0
    }
}, function() {
    showNextView();
});
BENEFITS

• Logic   and content from the same stack

• No   race conditions between native + web

• Reusability   & maintainability
3. Reacting to gestures
YUI().USE(“GESTURES”)
YUI.USE(“EVENT-FLICK”)

movieCarousel.on("flick", onMovieFlick, {
// only notify me if the flick covered
// more than 20px and was faster than 0.8px/ms
    minDistance:20,
    minVelocity:0.8,
    axis : “x”
});

function onMovieFlick (e) {
   //Go to the next movie
}
YUI().USE(“EVENT-MOVE”)



• Itprovides a set of synthetic events to detect
  gestures

• gesturemovestart, gesturemove, gesturemoveend.
movieCarousel.delegate("gesturemovestart", function(e) {

    var item = e.currentTarget,
        swipeEnd,
        isSwipeLeft,
        swipeStart;

    item.setData("swipeStart", e.pageX);
    item.once("gesturemoveend", function(e) {

        swipeStart = item.getData("swipeStart");
        swipeEnd = e.pageX;
        isSwipeLeft = (swipeStart - swipeEnd) >
MIN_SWIPE;

          if (isSwipeLeft) {
              //Go to the previous movie
          } else {
             //Go to the next movie
          }
    });
YUI().USE(“SCROLLVIEW”)
YUI().USE(“SCROLLVIEW”)
YUI().USE(“SCROLLVIEW”)



• Provides   scrollable content for touch enabled devices.

• Two   plugins: ScrollViewScrollbars & ScrollViewPaginator
HOW TO?

        <ul id=”movies”>
            <li>
                 <img src=”movie.jpeg”
alt=”somemovie”>
            </li>
        </ul>
YUI({...}).use("scrollview", function(Y){

 var scrollview = new Y.ScrollView({
         srcNode:"#movies",
         flick : {minVelocity:0.8},
         deceleration : 0.98,
         bounce: 0.1,
         width:"20em"
 });

});
4. Offline & save modes
OFFLINE


• Two distinctions: Offline mode & Save articles to
 read later

• In   both cases we are using native storage
OFFLINE MODE
Used to display the most recent data in case
             of no connectivity
OFFLINE MODE
Used to display the most recent data in case
             of no connectivity

             Data(native storage)
OFFLINE MODE
Used to display the most recent data in case
             of no connectivity

             Data(native storage)
OFFLINE MODE
Used to display the most recent data in case
             of no connectivity

             Data(native storage)




             Y.Lang.Substitute (for
                  templating)
OFFLINE MODE
Used to display the most recent data in case
             of no connectivity

              Data from Local
             Data(native storage)
                   storage




             Y.Lang.Substitute (for
                  templating)
OFFLINE(SAVE)
OFFLINE(SAVE)

Core files(Already cached)
OFFLINE(SAVE)

Core files(Already cached)


      Content
OFFLINE(SAVE)

       Core files(Already cached)


             Content

HTML
OFFLINE(SAVE)

       Core files(Already cached)


             Content

HTML    CSS
OFFLINE(SAVE)

       Core files(Already cached)


             Content

HTML    CSS            JS
OFFLINE(SAVE)

       Core files(Already cached)


             Content

HTML    CSS            JS          Media
SO...


• Ifyou need to store big files + media: Use
  native storage

• Otherwise   store JSON in localStorage & use
  templates
5. The bridge
THE BRIDGE


Two way communication between Native & Web
NATIVE->WEB
NATIVE->WEB
NATIVE->WEB
NATIVE->WEB
NATIVE -> WEB


• Call   directly into JS

• Using Y.Env    to expose global method

• Use Y.applyTo    to call into specific function
WEB -> NATIVE



• By   navigating to a local host/protocol

• You   can use : window.location or XHR
WINDOW.LOCATION
WINDOW.LOCATION
On your JS:

 window.location = myProtocol://performAction?param=foo
WINDOW.LOCATION
On your JS:

 window.location = myProtocol://performAction?param=foo

On your native code:

if([[request.URL scheme] isEqualToString:@"myProtocol"])
{
  //Parse the request, perform an action
}
else {
   return TRUE; //Navigate
}
XHR


• Cross   domain policies restrictions

• Works    if the content is loaded locally

• Can   send a response back
General best practices
var true = TRUE;

Everything you’ve learned
      still applies
- Keep your JS small
- Keep your JS small
- Don’t touch the DOM. Keep it
Small
- Keep your JS small
- Don’t touch the DOM. Keep it
Small
- Every byte counts as “double” in
mobile
Reduce your http requests:
Reduce your http requests:
- Pre-pack as much as you can.
Reduce your http requests:
- Pre-pack as much as you can.
- Use data URI for small images.
Reduce your http requests:
- Pre-pack as much as you can.
- Use data URI for small images.
- Use cached templates to load similar
views.
Perceived performance:
Give constant UI feedback
Shrink your images
Take advantage of the
       shinny:
Take advantage of the
       shinny:
- Imageless designs(CSS3)
Take advantage of the
       shinny:
- Imageless designs(CSS3)
- Hardware acceleration (don’t abuse
it)
Take advantage of the
       shinny:
- Imageless designs(CSS3)
- Hardware acceleration (don’t abuse
it)
- Use new semantic HTML5 elements
One more thing...
Got a cool idea? Build it!

http://yuilibrary.com/gallery/
FINAL THOUGHTS



• YUI3is well suited for both Hybrid and
 Mobile web apps.

• Everything   you need is already available
YUI.USE(“RESOURCES”)


• http://davidbcalhoun.com/2011/mobile-performance-manifesto

• http://www.yuiblog.com/blog/2011/01/17/video-yuiconf2010-
 desai/

• http://www.slideshare.net/nzakas/mobile-web-speed-bumps
YUI().USE(“THANK YOU”)

          @goonieiam


        http://yuilibrary.com
    http://yuilibrary.com/theater/

Mais conteúdo relacionado

Semelhante a Creating Hybrid mobile apps with YUI

Developing Mobile HTML5 Apps with Grails
Developing Mobile HTML5 Apps with GrailsDeveloping Mobile HTML5 Apps with Grails
Developing Mobile HTML5 Apps with Grails
GR8Conf
 
Solving Problems with YUI3: AutoComplete
Solving Problems with YUI3: AutoCompleteSolving Problems with YUI3: AutoComplete
Solving Problems with YUI3: AutoComplete
IsaacSchlueter
 
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Esri Nederland
 

Semelhante a Creating Hybrid mobile apps with YUI (20)

iPhone Appleless Apps
iPhone Appleless AppsiPhone Appleless Apps
iPhone Appleless Apps
 
The Inclusive Web: hands-on with HTML5 and jQuery
The Inclusive Web: hands-on with HTML5 and jQueryThe Inclusive Web: hands-on with HTML5 and jQuery
The Inclusive Web: hands-on with HTML5 and jQuery
 
HTML5와 모바일
HTML5와 모바일HTML5와 모바일
HTML5와 모바일
 
Fake it 'til you make it
Fake it 'til you make itFake it 'til you make it
Fake it 'til you make it
 
Txjs
TxjsTxjs
Txjs
 
Advanced #6 clean architecture
Advanced #6  clean architectureAdvanced #6  clean architecture
Advanced #6 clean architecture
 
Django Deployment with Fabric
Django Deployment with FabricDjango Deployment with Fabric
Django Deployment with Fabric
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on Mobile
 
Hosting Your Own OTA Update Service
Hosting Your Own OTA Update ServiceHosting Your Own OTA Update Service
Hosting Your Own OTA Update Service
 
Titanium Alloy Tutorial
Titanium Alloy TutorialTitanium Alloy Tutorial
Titanium Alloy Tutorial
 
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony AppsSymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
 
Web app
Web appWeb app
Web app
 
Web app
Web appWeb app
Web app
 
Developing Mobile HTML5 Apps with Grails
Developing Mobile HTML5 Apps with GrailsDeveloping Mobile HTML5 Apps with Grails
Developing Mobile HTML5 Apps with Grails
 
Docker presentasjon java bin
Docker presentasjon java binDocker presentasjon java bin
Docker presentasjon java bin
 
Solving Problems with YUI3: AutoComplete
Solving Problems with YUI3: AutoCompleteSolving Problems with YUI3: AutoComplete
Solving Problems with YUI3: AutoComplete
 
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
 
Dcjq node.js presentation
Dcjq node.js presentationDcjq node.js presentation
Dcjq node.js presentation
 
Palm Developer Day PhoneGap
Palm Developer Day PhoneGap Palm Developer Day PhoneGap
Palm Developer Day PhoneGap
 
From YUI3 to K2
From YUI3 to K2From YUI3 to K2
From YUI3 to K2
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Creating Hybrid mobile apps with YUI

Notas do Editor

  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
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. \n
  120. \n
  121. \n
  122. \n
  123. \n
  124. \n
  125. \n
  126. \n
  127. \n
  128. \n
  129. \n
  130. \n
  131. \n
  132. \n
  133. \n
  134. \n
  135. \n
  136. \n
  137. \n
  138. \n
  139. \n
  140. \n
  141. \n
  142. \n
  143. \n
  144. \n
  145. \n