Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
TVML Myths: or why you shouldn't write TVML off...
Search
sammyd
August 23, 2016
Programming
340
1
Share
TVML Myths: or why you shouldn't write TVML off... yet
Presented at 360|iDev 2016.
sammyd
August 23, 2016
More Decks by sammyd
See All by sammyd
Core Image: Great when it works
sammyd
1
550
iOS Views & Animations: Learning by stealing
sammyd
1
190
Machine Learning on Mobile—a primer
sammyd
0
130
Core ML: A whistlestop tour
sammyd
1
180
DIY DI
sammyd
2
130
iOSConfSG 2017: Decoding Codable
sammyd
3
210
Machine Learning: deciphering the hype
sammyd
0
170
Notify Me, Notify You. Aha!
sammyd
1
190
SwiftConf 2016: Concurrency on iOS
sammyd
1
200
Other Decks in Programming
See All in Programming
AIとRubyの静的型付け
ukin0k0
0
510
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
420
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.2k
AIエージェントと協働するCLI開発 — BunとOpenClawで学んだこと
yoshikouki
1
230
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
140
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
1.5k
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3k
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
17
5.1k
Claspは野良GASの夢をみるか
takter00
0
150
Oxcを導入して開発体験が向上した話
yug1224
4
270
[KCD Czech] eBPF Meets the GPU: Future of AI Infra Observability
doniacld
0
130
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
460
Featured
See All Featured
How to make the Groovebox
asonas
2
2.2k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
220
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
180
Site-Speed That Sticks
csswizardry
13
1.2k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Done Done
chrislema
186
16k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Speed Design
sergeychernyshev
33
1.8k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
310
Transcript
TVML Myths or why you shouldn't write TVML off... yet
Sam Davies | @iwantmyrealname | 360|iDev 2016
What is TVML?
Why is TVML so misunderstood?
Five Myths about TVML 1. You have to use a
server 2. You write TVML in JavaScript strings 3. Layout includes data 4. TVML is for media playback 5. Either TVML or native
You have to use a server
demo
Five Myths about TVML 1. You have to use a
server 2. You write TVML in JavaScript strings 3. Layout includes data 4. TVML is for media playback 5. Either TVML or native
You write TVML in JavaScript strings
Sample Code App.onLaunch = function(options) { var template =
'<document>' + '<loadingTemplate>' + '<activityIndicator>' + '<text>Hello World!</text>' + '</activityIndicator>' + '</loadingTemplate>' + '</document>'; var templateParser = new DOMParser(); var parsedTemplate = templateParser.parseFromString(template, "application/xml"); navigationDocument.pushDocument(parsedTemplate); }
In-bundle TVML 4 TVML engine just processes text 4 Doesn't
care where it comes from 4 Server offers advantages, but not required
demo
Five Myths about TVML 1. You have to use a
server 2. You write TVML in JavaScript strings 3. Layout includes data 4. TVML is for media playback 5. Either TVML or native
Layout includes data
<infoList> <info> <header> <title>Presenter</title> </header> <text>Sam Davies</text> </info> <info> <header>
<title>Tags</title> </header> <text>Short</text> <text>Glasses</text> <text>Funny Accent</text> </info> </infoList> <stack> <title>Droning-On II: Return of the Tedium</title> </stack>
the entirety of JavaScript at your fingertips
!
Templating Engine
{{MUSTACHE}}
class ResourceLoaderJS { ... getDocument(name) { var docString = this.nativeResourceLoader.loadBundleResource(name);
return this.domParser.parseFromString(docString, "application/xml"); } }
class ResourceLoaderJS { ... getDocument(name, data) { data = data
|| {}; var docString = this.nativeResourceLoader.loadBundleResource(name); var rendered = Mustache.render(docString, data); return this.domParser.parseFromString(rendered, "application/xml"); } }
class ResourceLoaderJS { ... getDocument(name, data) { data = data
|| {}; var docString = this.nativeResourceLoader.loadBundleResource(name); var rendered = Mustache.render(docString, data); return this.domParser.parseFromString(rendered, "application/xml"); } getJSON(name) { var jsonString = this.nativeResourceLoader.loadBundleResource(name); var json = JSON.parse(jsonString); return json; } }
<infoList> <info> <header> <title>Presenter</title> </header> <text>Sam Davies</text> </info> <info> <header>
<title>Tags</title> </header> <text>Short</text> <text>Glasses</text> <text>Funny Accent</text> </info> </infoList> <stack> <title>Droning-On II: Return of the Tedium</title> </stack>
<infoList> <info> <header> <title>Presenter</title> </header> <text>{{presenter}}</text> </info> <info> <header> <title>Tags</title>
</header> {{#tags}} <text>{{.}}</text> {{/tags}} </info> </infoList> <stack> <title>{{title}}</title> </stack>
{ "presenter": "Sam Davies", "tags": [ "Short", "Glasses", "Funny Accent"
], "title": "Droning-On II: Return of the Tedium" }
demo
Five Myths about TVML 1. You have to use a
server 2. You write TVML in JavaScript strings 3. Layout includes data 4. TVML is for media playback 5. Either TVML or native
TVML is for media playback
Not just media playback 4 ~20 different templates 4 Complex
nested layouts 4 Great for browsing 4 Apple uses TVML a lot
Five Myths about TVML 1. You have to use a
server 2. You write TVML in JavaScript strings 3. Layout includes data 4. TVML is for media playback 5. Either TVML or native
Either TVML or native
Hybrid TVML & "Native" 1. Call native functionality from TVML
2. Integrate native views into TVML 3. Use TVML views in native apps
Call Native Functionality from TVML 4 Use JavaScriptCore 4 Create
native function, vend to JS context 4 Wire it in with JS app
demo
Integrate native views into TVML app 4 Extend TVML with
custom tags 4 Add custom style attributes to TVML 4 Use as regular TVML
demo
Five Myths about TVML 1. You have to use a
server 2. You write TVML in JavaScript strings 3. Layout includes data 4. TVML is for media playback 5. Either TVML or native
TVML Limitations
TVML Limitations 4 Less control over appearance / layout 4
Have to write JavaScript 4 Out of comfort zone 4 Documentation & samples {are|were} terrible
TVML Positives 4 Can redeploy app without app review 4
Trivial to use a server 4 Powerful layouts, really easily 4 XML is a good language for declarative layouts
try it. you might like it.
git.io/v6MsR github.com/sammyd @iwantmyrealname raywenderlich.com