ionic + browserify by alexandre barbier - soirée mobile sfeir 05/05/2015

20
ionic + Browserify

Upload: sfeir

Post on 06-Aug-2015

321 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

ionic + Browserify

Page 2: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

I Me MineAlexandre Barbier

Front End dev @Sfeir

You can find me at:

@alexbrbr

Page 3: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

1 ecosystem

Page 4: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

Number of npm packages on

May 3, 2015

145,165

Page 5: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

Most packages and fastest

growth at the same time

145,165

Page 6: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

Examples of node core libraries

▪ events

▪ streams

▪ path

▪ url

▪ assert

▪ util

▪ querystring

▪ http

▪ vm

▪ crypto

Page 7: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

2

Page 8: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

We should write tiny reusable

modules that each just do one

thing.

“substack”

Page 9: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

▪ Use modules written in CommonJS / node.js

▪ Can both require and export modules

▪ Super easy to setup

▪ Tools for automation : watchify

Page 10: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

Using browserify in 3 steps

browserify main.js -o bundle.js

<script src=”bundle.js”></script>

npm install mymodule

Page 11: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

3 Example in an ionic app

Page 12: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

Stack :

Lots of functionality without backend with

Firebase + Browserify

Page 13: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

npm install elo-rank

Implementation of the elo-ranking system in

JavaScript.

Page 14: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

Created as a chess rating system,

adapted in video games,

basketball, Major League

Baseball, competitive programming

and esports.

Elo

2500 -> grand master

1200 -> new player

victory ~+15 points

Page 15: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

▪ Expose the npm module elo-rank

as an angular constant :

▪ angular.module(‘...’)

.constant(‘eloRank’, require(‘elo-rank’)(32);

Page 16: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

▪ So it’s easily reusable using dependency

injection “the angular way”

▪ angular.module(‘...’)

.controller(‘...’, function($scope, eloRank) {

var test = eloRank.getExpected(1200, 1400);

//0.2402530733520421

});

Page 17: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

Let’s see some code !!!

Page 18: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

Conclusion

You might want to use Browserify if you :

▪ Need an npm module for a specific use

▪ Want to share some reusable code on npm

▪ Want to use node.js syntax inside angular/ionic

Also it might be useful in a mobile environment to

avoid server api calls

Page 19: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

Links

Special thanks to all the people who made and released

these awesome resources for free:

▪ Browserify handbook by substack : https://github.

com/substack/browserify-handbook

▪ Fast Browserify builds for gulp : https://github.

com/gulpjs/gulp/blob/master/docs/recipes/fast-

browserify-builds-with-watchify.md

Page 20: Ionic + Browserify by Alexandre Barbier - Soirée Mobile Sfeir 05/05/2015

Thanks!ANY QUESTIONS?

You can find me at:

@alexbrbr on Twitter