Jeff English: Demystifying Module Development - How to Extend Titanium
Upcoming SlideShare
Loading in...5
×
 

Jeff English: Demystifying Module Development - How to Extend Titanium

on

  • 5,985 views

The ability to extend your application with custom functionality, whether an external library or your own custom library, opens up numerous possibilities for what you can create. Titanium enables this ...

The ability to extend your application with custom functionality, whether an external library or your own custom library, opens up numerous possibilities for what you can create. Titanium enables this with what are called 'modules'. Modules provide a bridge between your Javascript application code and your native library code. Getting started writing your own modules can seem confusing, but once your understand the architecture of a module and how it integrates with the Titanium platform you will be able to add your own functionality in short order.

In this session you will learn:

How to create your module project
How to call methods and pass parameters to your module from your Javascript code
How to make callbacks into your Javascript code from your module

This session is for anyone interested in understanding module development and how to get started.

Jeff English is the Modules Development Manager at Appcelerator. Jeff and his team designed and developed many of the Appcelerator modules found in the Marketplace.

Statistics

Views

Total Views
5,985
Views on SlideShare
3,885
Embed Views
2,100

Actions

Likes
7
Downloads
88
Comments
0

23 Embeds 2,100

http://gndo.blogspot.jp 1099
http://gndo.blogspot.com 517
http://developer.appcelerator.com 250
http://www.appcelerator.com 145
http://paper.li 25
http://sharkpp.tumblr.com 17
http://www.johnnydaisuke.info 10
http://tidevcn.com 7
http://a0.twimg.com 4
http://www13.jimdo.com 3
http://gndo.blogspot.hk 3
http://gndo.blogspot.de 3
http://cache.baidu.com 3
http://gndo.blogspot.co.uk 2
http://webcache.googleusercontent.com 2
http://b.hatena.ne.jp 2
http://delicious.com 2
http://us-w1.rockmelt.com 1
http://gndo.blogspot.tw 1
http://gndo.blogspot.in 1
http://www55.jimdo.com 1
http://www.verious.com 1
http://gndo.blogspot.no 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Jeff English: Demystifying Module Development - How to Extend Titanium Jeff English: Demystifying Module Development - How to Extend Titanium Presentation Transcript

  • Demystifying Module Development Jeff English
  • Jeff English•  30+ years of software development•  Cross-platform SDKs, operating system development, games, mobile encryption management, et. al.•  50+ consumer, commercial, and enterprise applications•  “Real-World Programming for OS/2”Engineering Manager, Modulesjenglish@appcelerator.com
  • Dilbert, September 8, 1992 Copyright © 1992, Scott Adams
  • What Are Modules? Extensions to the core Titanium platform Titanium itself is written as a collection of modules Written in native code iOS (Objective-C), Android(Java), JavaScript (JavaScript) Provide a bridge between JS and native code Methods, Properties, Notifications, Data Types, Assets
  • Module Features Life Cycle Events Method Parameters Module loading, proxy loading, view Type validation, type conversion, proxy loading pass-by-value / reference Properties Callbacks & Events Types, getters, settings, property Event registration, asynchronous change notifications notifications, synchronous callbacks Methods Miscellaneous Method signatures / annotations Assets, documentation, example, license, manifest, packaging
  • Basic Module Development (iOS) Create a module titanium create --platform=iphone --type=module --dir=. --name=calc --id=com.companyname.calc Build a module ./build.py Test a module titanium run Deploy a module Copy module zip file into system folder or application folder
  • Basic Module Development (Android) Create a module titanium create --platform=android --type=module --dir=. --name=calc --id=org.companyname.calc --android=/usr/android-sdk Build a module ant Test a module ant run Deploy a module Copy module zip file into system folder or application folder
  • Basic Module Architecture require Module (TiModule / KrollModule) create Proxy (TiProxy / KrollProxy) JavaScript createView View Proxy (TiViewProxy) View (TiUIView)
  • JavaScript / Module Interactionsvar m = require(‘…’);!m.fooInt = 42;! fooInt propertym.fooString = ‘Hello World’;!Ti.API.info(m.fooString);! fooString propertym.foo({ X: 5, Y: 10 });! foo methodm.addEventListener(! ‘myEvent’,! myHandler);!function myHandler(e) {! Signal Event Ti.API.info(‘myEvent’);!}!
  • JavaScript / Proxy Interactionsvar m = require(‘…’);!var p = m.createBar(…);! createBar methodp.fooInt = 42;! fooInt propertyp.fooString = ‘Hello World’;!Ti.API.info(m.fooString);! fooString propertyp.foo({ X: 5, Y: 10 });! foo methodp.addEventListener(! ‘myEvent’,! myHandler);!function myHandler(e) {! Signal Event Ti.API.info(‘myEvent’);!}!
  • JavaScript / ViewProxy Interactionsvar m = require(‘…’);!var p = m.createView(…);! createView methodp.fooInt = 42;! fooInt propertyp.fooString = ‘Hello World’;!Ti.API.info(m.fooString);! fooString propertyp.foo({ X: 5, Y: 10 });! foo methodp.addEventListener(! ‘myEvent’,! myHandler);!function myHandler(e) {! Signal Event Ti.API.info(‘myEvent);!}!
  • Proxy Properties Properties can be set in the constructor Setter is automatically called Properties can be set directly after proxy creation Many primitive values are automatically converted iOS Properties Getters and Setters can be defined by using @property or property signatures Android Properties Getters and Setters can be defined by using @Kroll.getProperty and @Kroll.setProperty annotations
  • Proxy Methods Module methods can be exposed to JS iOS – Signature determines availability (id)methodName:(id)args (void)methodName:(id)args Android – Annotations determine availability @KrollMethod Use KrollInvocation if your method requires the current activity
  • Method Parameters Parameters can be passed from JS to your methods iOS All parameters are passed in an NSArray object Use TiUtils methods to get correct datatype Android All parameters are passed as defined – KrollDict recommended Use validation methods (e.g. TiConvert) to get correct datatype
  • Callbacks and Events Methods exist for notifying JS of module events Recommended to use events rather than callbacks when possible iOS fireEvent and _fireEventToListener call Android fireEvent and fireSingleEvent callAsync and callSync
  • Miscellaneous Assets iOS Build Options titanium.xcconfig Android Build Options timodule.xml Manifest Documentation
  • Miscellaneous (cont) LICENSE Example
  • Module DevelopmentGuide ReferenceModuleLife Cycle eventsKroll usageCut-and-paste example code
  • Module LoadModule Unload
  • Proxy CreateProxy Destroy
  • ViewProxy Create
  • ViewProxy Create
  • Parameters Demo
  • Module Development Resources Module Development Guide for iOS Module Development Guide for Android Open source modules available on GitHub https://github.com/appcelerator/titanium_modules Module Development Guide reference module moddevguide
  • Questions