1 / 7

Putting it together

Putting it together. http://www.flickr.com/photos/ourcage/8343799386/. Let's put the pieces together. Creating a little native mobile app To show how to combine cloud with native mobile To illustrate some maintainability-related issues Including modular code structure

brody
Download Presentation

Putting it together

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Putting it together http://www.flickr.com/photos/ourcage/8343799386/

  2. Let's put the pieces together • Creating a little native mobile app • To show how to combine cloud with native mobile • To illustrate some maintainability-related issues • Including modular code structure • Including use of events to decouple code • To introduce a few new APIs • Detecting network connection • Closing windows / back button • Minor styling APIs

  3. Key functionality of this example app • For a native mobile app user… • Browse through a list of short textual snippets previously entered • Enter a new textual snippet • Native mobile app should automatically detect network connectivity & copy to server

  4. Code Walkthrough: DearDiary (Note: tested only on Android emulator)

  5. Detecting network connection • Key concepts • Network connectivity is flaky • You can ask the operating system for the current network connection status • Key code • if Titanium.Network.networkType != Titanium.Network.NETWORK_NONE

  6. Modular code structure • Key concepts • Splitting into modules promotes maintainability • Each module (file) exposes selected functions (effectively presenting an interface) • Key code • Put related code in the same JS file; put unrelated code in different JS files • exports.fnName = function(…) to declare a function • varmylib = require('filename') to reference a module

  7. Decoupling code using events • Key concepts • Exposing events makes it possible to trigger code without explicitly referencing that code • When something happens in object Y, then object Y can cause function X to run without Y having to reference X • Key code • object.fireEvent('myevt', param) to fire off an event • object.addEventListener('myevt', function(param) { … }); to register event handler

More Related