Replace Angular with React. Make the move from the MEAN stack to the powerful MERN Stack!
Come and learn about the MERN stack. No, that isn't a typo. The MERN stack is Mongo, Express, and Node, with React instead of Angular. While both React and Angular are remarkable JavaScript technologies, React comes with less baggage. There is no TypeScript, no annotations, no bossy framework telling you how to do everything.
2. Troy Miles
• Troy Miles aka the RocknCoder
• Over 37 years of programming
experience
• Speaker and author
• bit.ly/rc-jquerybook
• rockncoder@gmail.com
• @therockncoder
• Now a lynda.com Author!
3. Build Mobile Apps!
• Develop mobile apps with
Ionic and AngularJS
• Learn the Ionic CLI
• Fetch data via ajax
• Deploy your app to Android &
iOS
• bit.ly/ionicvideo
9. Get Git
• Get is a mandatory tool for using all open source
tools
• lots of free tutorials on how to use it
• https://www.codeschool.com/learn/git
• https://git-scm.com/
10. The MEAN Stack
• MEAN is a free and open-source JavaScript
software stack for building dynamic web sites and
web applications.
• Term coined by Valeri Karpov
11. MongoDB
• MongoDB is an open-source, document database
designed for ease of development and scaling.
• v3.2
• Initial release - 2009
• https://www.mongodb.org/
14. NodeJS
• Node.js® is a platform built on Chrome's V8
JavaScript runtime for easily building fast, scalable
network applications.
• v7.2.0
• https://nodejs.org/
15. Benefits of the MEAN Stack
• Isomorphic JavaScript
• Open Source / Community Driven
• Performance
• Low Cost
16. Isomorphic JavaScript
• One language all the way thru
• Client/Server JavaScript
• JSON as the data transport format
• BSON as the data storage format
• JavaScript to control Mongo DB
17. Why is JavaScript Beautiful?
• It is a Functional Language - Closer to Lisp and
Scheme than Java or C
• First Class Functions
• Dynamic Objects
• Loose Typing
• and more...
19. How to use ES6 today?
• Use only the latest browsers
• Use a transpiler: Babel, Traceur, Closure,
TypeScript
• Use Node.js
• https://kangax.github.io/compat-table/es6/
24. Top DB Engines
1. Oracle
2. MySQL
3. MS SQL Server
4. MongoDB
5. PostgreSQL
6. DB2
7. MS Access
8. Cassandra
9. Redis
10.SQLite
25. Who Uses It?
• Craigslist
• eBay
• Foursquare
• SourceForge
• Viacom
• Expedia
• LinkedIn
• Medtronic
• eHarmony
• CERN
• and more
26. When to Use Mongo?
• Document Database
• High Performance
• High Availability
• Easy Scalability
• Geospatial Data
27. What is a Document?
• An ordered set of keys and values
• Like JavaScript objects
• No duplicate keys allowed
• Type and case sensitive
• Field order is not important nor guaranteed
29. Node v7
• Merged with the io.js project, which was at 3.x
• New version of Chrome V8
• Supports ES6
• Faster
• node -v
30. Node Package Manager
• Or npm for short
• version: npm -v
• upgrade npm: npm install npm -g
• (officially, npm doesn’t stand for anything, anymore)
31. package.json
• required properties (error if missing)
• name & version
• optional properties (warning if missing)
• description, repository, & license
• other properties
• scripts, dependencies, config, etc.
32. Use Environment Vars
• process.env object holds all environment vars
• Reading: var connect = process.env.connect;
• Writing: process.env.mode = ‘test’;
• NEVER PUT SECRET STUFF IN SOURCE CODE!
36. Angular 2 main concepts
• Component
• Data binding
• Service
• Directive
• Dependency injection
• Module
37. Metadata
• Metadata is extra information which gives angular
more info
• @Component tells angular the class is a
component
• @Directive tells angular the class is a directive
38. Component
• A class with component metadata
• Responsible for a piece of the screen referred to as
view.
• Template is a form HTML that tells angular how to
render the component.
• Metadata tells Angular how to process a class
40. Template/View
• Is a way to describe a view using HTML
• Templates can be included with the component
• Or as a URL link to an HTML file
• Best practice is to use an HTML file
41. Data Binding
C/D Attribute Binding type
—> {{ value }} one-way
—> [property] = “value” property
<— (event) = “handler” event
<—> [(ng-model)] = “property” two-way
42. Service
• “Substitutable objects that are wired together using
dependency injection (DI)”
• Used to share code across an app
• Lazily instantiated
• Angular has no “Service” defined type
43. Directive
• A class with directive metadata
• Two kinds: attribute & structural
• Attribute directives alter the look or behavior of an
existing element
• Structural directives alter the layout by adding,
removing, and replacing elements in the DOM
• A component is a directive with a view
46. Dependency Injection
• A way to supply a new instance of a class with the
fully-formed dependencies it needs
• Most dependencies are services
• Angular know which services a components by
looking at the types of its constructor parameters
• Services are injected by an Injector which uses a
Provider to create the service
47. Module
• Modules are optional but a best practice
• export tells TypeScript that the resource is a
module available for other modules
• import tells TypeScript the resource in a module
• Angular ships a collection library modules
49. Webpack?
• Module bundler
• Replaces System.JS
• Works with JS, CSS, and HTML
• Minifies, concatenates, and bundles
50. The MERN Stack
• Keep Mongo, Express, and Node
• Replace Angular with React
• HashNode create mern-cli to scaffold a mern app
• http://mern.io/
51. MERN CLI
• A scaffolding tool to minimize setup time
• npm install -g mern-cli
• mern init <app_name>
• cd <app_name>
• npm install
• npm start
52. mern commands
Command Purpose
mern init <name> initialize a MERN app
mern list List MERN variants
mern search <term> Search for a variant
mern info <term> View details of a variant
merng generates a component
53. npm commands
Command Purpose
npm run start start dev server
npm run bs bundles, starts prod
npm run test starts test runner
npm run watch:test starts test runner in watch
npm run coverage generates coverage report
npm run lint runs linter
54. generator commands
Command Purpose
dumb-s <name> dumb comp in shared
dumb-m <name> dump comp in module
functional-s <name> functional comp in shared
functional-m <name> functional comp in module
module <name> create a module
55. React
• A JavaScript library for building UIs
• Created by Facebook & Instagram
• Initial release March 2013
• Highly recommend reading their license
56. React
• Virtual DOM
• One-way data flow
• JSX - JavaScript eXtension allows in HTML
generation
• Component-based
57. Flux
• A pattern for managing data flow in your app
• One way data flow
• 4 main parts: Dispatcher, Store, Action, & View
58. The 4 main parts
• Dispatcher: receives actions & dispatches them to
stores
• Store: holds the data of an app
• Action: define app’s internal API
• View: displays the data from stores
60. Redux
• A predictable state container for JS apps
• Works well with React Native
• An alternative to & inspired by Flux
• Single store for the entire app
• Makes it easier to hot-load your app
61. React Router
• A complete routing library for React
• Keeps UI in sync with URL
64. Summary
• React is easier to learn than Angular
• When you add in parts like Redux, Flux and React
Router, React is more complex than angular
• In the end choose what is best for you and your
team
• Don’t give in to dogma