SlideShare a Scribd company logo
1 of 23
THE SILVER BULLET FOR IONIC1
David Hohl
www.fishme.de
@fishme2010
Meetup 08.12.2016
Technology Evangelist
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
• Since 1998 web developer
• Evangelist for…
• Cordova with Ionic
• PHP for CMS
• Clients: NDR, Boston Consulting Group,
Miele, Blick, Intersport, Update CRM,
SPD, Adidas, Atomic, Comscore,
Voest Alpine, Asus and more;
#RC – 03/1981
David Hohl
Yes, but not for you!
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
We want to talk about …
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
Why we should use
Typescript?
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
• Clean Code
• Readable
• Better reusable
• Less bugs
• OOP
Clean Code?
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
• Good Structure
• Ease to understand
• Codebase
• Readable
• Class/Function/Var Naming
• No scope soup
• No root scope soup
I will write Typescript!
I will write Typescript!
I will write Typescript!
I will write Typescript!
Where can I use Typescript?
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
• Service
• Controller
• Directive
• Filter
Most common
ngModule.controller(Controller.ID, Controller);
ngModule.directive(Directive.ID, Directive);
ngModule = angular.module(’MobileApp.Application',
['ui.router', 'ionic', 'templates', 'ngMockE2E', 'pascalprecht.translate',
'ngSanitize', 'toastr', 'ngAnimate’]
ngModule.filter(Filter.ID, Filter);
ngModule.service(Service.ID, Service);
Where can I use Typescript?
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
• Project
• Helper
ngModule.run(…)
ngModule.config(..)
Angular.run(…)
Angular.config(..)
Automate it!
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
namespace MyProject.Service
namespace MyProject.Controller
namespace MyProject.Directive
namespace MyProject.Filter
Example with a service
_.each(Services, (Service: any) => {
ngModule.service(ID, Service);
}
TSD – Definition
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
tsd install angulartics
tsd update –s –o
tsd.json (config)
TSD – Holl(rr)ow(r) Bible?
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
• Interfaces
• Definition
• Important!
private $http: angular.IHttpService,
private $location: ng.ILocationService,
private $state: ng.ui.IStateService,
private $rootScope: ng.IRootScopeService
this.$http(this.requestConfig).then(
(response: ng.IHttpPromiseCallbackArg<any>) => {
….
}));
https://palantir.github.io/tslint
TSD – Holl(rr)ow(r) Bible?
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
• Way out?
/* tslint:disable */ - Disable all rules for the rest of the file
/* tslint:enable */ - Enable all rules for the rest of the file
/* tslint:disable:rule1 rule2 rule3... */
/* tslint:disable:semicon, qutemark */
Object not define -> use instead as Array
https://palantir.github.io/tslint
Controller and viewModels 1/3
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
• Readable
• OOP
export class AppController<T> {
public scope: ng.IScope;
public viewModel: T;
constructor(scope: ng.IScope, ModelType: { new (): T; }) {
this.scope = scope;
this.viewModel = new ModelType();
this.scope["controller"] = this;
this.scope.$on("$ionicView.loaded", _.bind(this.view_loaded, this));
this.scope.$on("$ionicView.enter", _.bind(this.view_enter, this));
export class AnimalController extends
AppController<ViewModels.AnimalViewModel>{….}
Controller and viewModels 2/3
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
• Readable
• OOP
export class AnimalViewModel {
public name: string;
public age: number;
public YouNowOlder() {
this.age++;
}
}
Controller… (same like $scope.name = ‘dog’;
this.viewModel.name = ’dog’;
Controller and viewModels 2/3
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
ViewModel Animal
Controller Dog Controller Cat
viewModel.YouNowOlder() viewModel.YouNowOlder()
Controller and viewModels 2/3
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
ViewModel Animal
Controller Snake
viewModel.YouNowOlder()
ViewModel Reptile extend ViewModel.Animal
Controller and viewModels 3/3
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
• Create Models with functions
• Reuseable! Clean Code! Enjoy it!
<button ng-click=”controller.viewModel.animalYouNowOlder()”>
I’m {{viewModel.age}}
</button>
Injection?
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
public static get $inject(): string[] {
return [
'$scope',
'$rootScope',
'$stateParams',
Services.Tracking.ID
];
}
constructor(
$scope: ng.IScope,
private $rootScope: IRootScopeService,
private $stateParams: ISearchStateParams,
private Tracking: Services.Tracking
) {
super($scope, ViewModels.SearchViewModel);
}
Better Code
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
1) example
if (animal === ‘dog’)
2) Declare where ever you can!
3) no return? public myAnimal(): void instead of any
4) Example don’t use >any<
public myAnimal() : string | boolean {
if (myVar) return ‘dog’;
If (myVar) return true;
}
Some Tipps and Tricks
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
• Use WebStorm
• Use Getters & Setters
• Don’t define functions in an interface
• Use interface for JSONs or Objects
• Use namespaces
• Use let instead of var
• Create for each Class a new File
• Use Static instead of Public if it is possible
• Callbacks: use “response => {}” instead of function(response) then you can use
this inside otherwise you have to copy the instance
Beginner Problems
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
• Which Type?
• Where I can find it?
• How to include Angular Code in Typescript?
• Object not defined like
animal.name use animal[‘name’]
Documentation
Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
THE SILVER BULLET FOR IONIC1
David Hohl
www.fishme.de
@fishme2010
Meetup 08.12.2016
THANK YOU – ENJOY TYPESCRIPT!

More Related Content

Similar to Ionic Framework and Typescript

FOSDEM 2024 Neo in the Matrix
FOSDEM 2024 Neo in the MatrixFOSDEM 2024 Neo in the Matrix
FOSDEM 2024 Neo in the MatrixOlimex Bulgaria
 
MongoDB In Production At Sailthru
MongoDB In Production At SailthruMongoDB In Production At Sailthru
MongoDB In Production At Sailthruibwhite
 
Hands on with Apache Spark
Hands on with Apache SparkHands on with Apache Spark
Hands on with Apache SparkDan Lynn
 
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...Oleksii Holub
 
Mongo at Sailthru (MongoNYC 2011)
Mongo at Sailthru (MongoNYC 2011)Mongo at Sailthru (MongoNYC 2011)
Mongo at Sailthru (MongoNYC 2011)ibwhite
 
Drupal - Changing the Web by Connecting Open Minds - Josef Dabernig
Drupal - Changing the Web by Connecting Open Minds - Josef DabernigDrupal - Changing the Web by Connecting Open Minds - Josef Dabernig
Drupal - Changing the Web by Connecting Open Minds - Josef DabernigDrupalCampDN
 
Leweb09 Building Wave Robots
Leweb09 Building Wave RobotsLeweb09 Building Wave Robots
Leweb09 Building Wave RobotsPatrick Chanezon
 
What's New in Neo4j 2.0 - Andreas Kollegger @ GraphConnect Boston + Chicago 2013
What's New in Neo4j 2.0 - Andreas Kollegger @ GraphConnect Boston + Chicago 2013What's New in Neo4j 2.0 - Andreas Kollegger @ GraphConnect Boston + Chicago 2013
What's New in Neo4j 2.0 - Andreas Kollegger @ GraphConnect Boston + Chicago 2013Neo4j
 
EclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them allEclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them allMarc Dutoo
 
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open WideOCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open WideOCCIware
 
Rapid Response: Debugging and Profiling to the Rescue
Rapid Response: Debugging and Profiling to the RescueRapid Response: Debugging and Profiling to the Rescue
Rapid Response: Debugging and Profiling to the RescueEric Kavanagh
 
05 integrate redis
05 integrate redis05 integrate redis
05 integrate redisErhwen Kuo
 
I/O 2011 報告会 ADKで遊んでみた
I/O 2011 報告会 ADKで遊んでみたI/O 2011 報告会 ADKで遊んでみた
I/O 2011 報告会 ADKで遊んでみたMakoto Yamazaki
 
Defcon 22-blake-self-cisc0ninja-dont-ddos-me-bro
Defcon 22-blake-self-cisc0ninja-dont-ddos-me-broDefcon 22-blake-self-cisc0ninja-dont-ddos-me-bro
Defcon 22-blake-self-cisc0ninja-dont-ddos-me-broPriyanka Aash
 
From Android NDK To AOSP
From Android NDK To AOSPFrom Android NDK To AOSP
From Android NDK To AOSPMin-Yih Hsu
 
Android Developer Meetup
Android Developer MeetupAndroid Developer Meetup
Android Developer MeetupMedialets
 
Real User Measurement Expert Panel by SOASTA
Real User Measurement Expert Panel by SOASTAReal User Measurement Expert Panel by SOASTA
Real User Measurement Expert Panel by SOASTASOASTA
 
Open Hardware Summit 2014
Open Hardware Summit 2014Open Hardware Summit 2014
Open Hardware Summit 2014Drew Fustini
 
DevOps Columbus Meetup Kickoff - Infrastructure as Code
DevOps Columbus Meetup Kickoff - Infrastructure as CodeDevOps Columbus Meetup Kickoff - Infrastructure as Code
DevOps Columbus Meetup Kickoff - Infrastructure as CodeMichael Ducy
 

Similar to Ionic Framework and Typescript (20)

OpenStack Summit Hong Kong
OpenStack Summit Hong KongOpenStack Summit Hong Kong
OpenStack Summit Hong Kong
 
FOSDEM 2024 Neo in the Matrix
FOSDEM 2024 Neo in the MatrixFOSDEM 2024 Neo in the Matrix
FOSDEM 2024 Neo in the Matrix
 
MongoDB In Production At Sailthru
MongoDB In Production At SailthruMongoDB In Production At Sailthru
MongoDB In Production At Sailthru
 
Hands on with Apache Spark
Hands on with Apache SparkHands on with Apache Spark
Hands on with Apache Spark
 
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...
 
Mongo at Sailthru (MongoNYC 2011)
Mongo at Sailthru (MongoNYC 2011)Mongo at Sailthru (MongoNYC 2011)
Mongo at Sailthru (MongoNYC 2011)
 
Drupal - Changing the Web by Connecting Open Minds - Josef Dabernig
Drupal - Changing the Web by Connecting Open Minds - Josef DabernigDrupal - Changing the Web by Connecting Open Minds - Josef Dabernig
Drupal - Changing the Web by Connecting Open Minds - Josef Dabernig
 
Leweb09 Building Wave Robots
Leweb09 Building Wave RobotsLeweb09 Building Wave Robots
Leweb09 Building Wave Robots
 
What's New in Neo4j 2.0 - Andreas Kollegger @ GraphConnect Boston + Chicago 2013
What's New in Neo4j 2.0 - Andreas Kollegger @ GraphConnect Boston + Chicago 2013What's New in Neo4j 2.0 - Andreas Kollegger @ GraphConnect Boston + Chicago 2013
What's New in Neo4j 2.0 - Andreas Kollegger @ GraphConnect Boston + Chicago 2013
 
EclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them allEclipseCon 2016 - OCCIware : one Cloud API to rule them all
EclipseCon 2016 - OCCIware : one Cloud API to rule them all
 
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open WideOCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
OCCIware Project at EclipseCon France 2016, by Marc Dutoo, Open Wide
 
Rapid Response: Debugging and Profiling to the Rescue
Rapid Response: Debugging and Profiling to the RescueRapid Response: Debugging and Profiling to the Rescue
Rapid Response: Debugging and Profiling to the Rescue
 
05 integrate redis
05 integrate redis05 integrate redis
05 integrate redis
 
I/O 2011 報告会 ADKで遊んでみた
I/O 2011 報告会 ADKで遊んでみたI/O 2011 報告会 ADKで遊んでみた
I/O 2011 報告会 ADKで遊んでみた
 
Defcon 22-blake-self-cisc0ninja-dont-ddos-me-bro
Defcon 22-blake-self-cisc0ninja-dont-ddos-me-broDefcon 22-blake-self-cisc0ninja-dont-ddos-me-bro
Defcon 22-blake-self-cisc0ninja-dont-ddos-me-bro
 
From Android NDK To AOSP
From Android NDK To AOSPFrom Android NDK To AOSP
From Android NDK To AOSP
 
Android Developer Meetup
Android Developer MeetupAndroid Developer Meetup
Android Developer Meetup
 
Real User Measurement Expert Panel by SOASTA
Real User Measurement Expert Panel by SOASTAReal User Measurement Expert Panel by SOASTA
Real User Measurement Expert Panel by SOASTA
 
Open Hardware Summit 2014
Open Hardware Summit 2014Open Hardware Summit 2014
Open Hardware Summit 2014
 
DevOps Columbus Meetup Kickoff - Infrastructure as Code
DevOps Columbus Meetup Kickoff - Infrastructure as CodeDevOps Columbus Meetup Kickoff - Infrastructure as Code
DevOps Columbus Meetup Kickoff - Infrastructure as Code
 

Recently uploaded

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 

Recently uploaded (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 

Ionic Framework and Typescript

  • 1. THE SILVER BULLET FOR IONIC1 David Hohl www.fishme.de @fishme2010 Meetup 08.12.2016
  • 2. Technology Evangelist Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - • Since 1998 web developer • Evangelist for… • Cordova with Ionic • PHP for CMS • Clients: NDR, Boston Consulting Group, Miele, Blick, Intersport, Update CRM, SPD, Adidas, Atomic, Comscore, Voest Alpine, Asus and more; #RC – 03/1981 David Hohl
  • 3. Yes, but not for you! Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
  • 4. We want to talk about … Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
  • 5. Why we should use Typescript? Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - • Clean Code • Readable • Better reusable • Less bugs • OOP
  • 6. Clean Code? Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - • Good Structure • Ease to understand • Codebase • Readable • Class/Function/Var Naming • No scope soup • No root scope soup I will write Typescript! I will write Typescript! I will write Typescript! I will write Typescript!
  • 7. Where can I use Typescript? Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - • Service • Controller • Directive • Filter Most common ngModule.controller(Controller.ID, Controller); ngModule.directive(Directive.ID, Directive); ngModule = angular.module(’MobileApp.Application', ['ui.router', 'ionic', 'templates', 'ngMockE2E', 'pascalprecht.translate', 'ngSanitize', 'toastr', 'ngAnimate’] ngModule.filter(Filter.ID, Filter); ngModule.service(Service.ID, Service);
  • 8. Where can I use Typescript? Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - • Project • Helper ngModule.run(…) ngModule.config(..) Angular.run(…) Angular.config(..)
  • 9. Automate it! Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - namespace MyProject.Service namespace MyProject.Controller namespace MyProject.Directive namespace MyProject.Filter Example with a service _.each(Services, (Service: any) => { ngModule.service(ID, Service); }
  • 10. TSD – Definition Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - tsd install angulartics tsd update –s –o tsd.json (config)
  • 11. TSD – Holl(rr)ow(r) Bible? Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - • Interfaces • Definition • Important! private $http: angular.IHttpService, private $location: ng.ILocationService, private $state: ng.ui.IStateService, private $rootScope: ng.IRootScopeService this.$http(this.requestConfig).then( (response: ng.IHttpPromiseCallbackArg<any>) => { …. })); https://palantir.github.io/tslint
  • 12. TSD – Holl(rr)ow(r) Bible? Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - • Way out? /* tslint:disable */ - Disable all rules for the rest of the file /* tslint:enable */ - Enable all rules for the rest of the file /* tslint:disable:rule1 rule2 rule3... */ /* tslint:disable:semicon, qutemark */ Object not define -> use instead as Array https://palantir.github.io/tslint
  • 13. Controller and viewModels 1/3 Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - • Readable • OOP export class AppController<T> { public scope: ng.IScope; public viewModel: T; constructor(scope: ng.IScope, ModelType: { new (): T; }) { this.scope = scope; this.viewModel = new ModelType(); this.scope["controller"] = this; this.scope.$on("$ionicView.loaded", _.bind(this.view_loaded, this)); this.scope.$on("$ionicView.enter", _.bind(this.view_enter, this)); export class AnimalController extends AppController<ViewModels.AnimalViewModel>{….}
  • 14. Controller and viewModels 2/3 Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - • Readable • OOP export class AnimalViewModel { public name: string; public age: number; public YouNowOlder() { this.age++; } } Controller… (same like $scope.name = ‘dog’; this.viewModel.name = ’dog’;
  • 15. Controller and viewModels 2/3 Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - ViewModel Animal Controller Dog Controller Cat viewModel.YouNowOlder() viewModel.YouNowOlder()
  • 16. Controller and viewModels 2/3 Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - ViewModel Animal Controller Snake viewModel.YouNowOlder() ViewModel Reptile extend ViewModel.Animal
  • 17. Controller and viewModels 3/3 Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - • Create Models with functions • Reuseable! Clean Code! Enjoy it! <button ng-click=”controller.viewModel.animalYouNowOlder()”> I’m {{viewModel.age}} </button>
  • 18. Injection? Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - public static get $inject(): string[] { return [ '$scope', '$rootScope', '$stateParams', Services.Tracking.ID ]; } constructor( $scope: ng.IScope, private $rootScope: IRootScopeService, private $stateParams: ISearchStateParams, private Tracking: Services.Tracking ) { super($scope, ViewModels.SearchViewModel); }
  • 19. Better Code Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - 1) example if (animal === ‘dog’) 2) Declare where ever you can! 3) no return? public myAnimal(): void instead of any 4) Example don’t use >any< public myAnimal() : string | boolean { if (myVar) return ‘dog’; If (myVar) return true; }
  • 20. Some Tipps and Tricks Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - • Use WebStorm • Use Getters & Setters • Don’t define functions in an interface • Use interface for JSONs or Objects • Use namespaces • Use let instead of var • Create for each Class a new File • Use Static instead of Public if it is possible • Callbacks: use “response => {}” instead of function(response) then you can use this inside otherwise you have to copy the instance
  • 21. Beginner Problems Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl - • Which Type? • Where I can find it? • How to include Angular Code in Typescript? • Object not defined like animal.name use animal[‘name’]
  • 22. Documentation Meetup 08.12.2016 The Silver Bullet for Ionic1 – David Hohl -
  • 23. THE SILVER BULLET FOR IONIC1 David Hohl www.fishme.de @fishme2010 Meetup 08.12.2016 THANK YOU – ENJOY TYPESCRIPT!