Use
Angular
for better
React apps
Martin Hochel
@martin_hotell
FrontendCon, PL
Slide 2
Slide 2 text
Martin Hochel
Principal SE, GDE WEB
Prague / Czech Republic
@martin_hotell
medium.com/@martin_hotell
github.com/hotell
Slide 3
Slide 3 text
What I like about Angular
Slide 4
Slide 4 text
What I like about Angular
Official style guides
Architecture
DI
TypeScript guarantees
Tooling
Very tasty!
Slide 5
Slide 5 text
What I dislike about Angular
Slide 6
Slide 6 text
What I dislike about Angular
Component model
Angular modules
Proprietary DSL + HTML like templates
Change Detection / Dirty checking
Slide 7
Slide 7 text
What I like about React
Slide 8
Slide 8 text
What I like about React
Simple/Robust Component model
It’s just javascript (functions and classes) #dealWithIt
Testability
Mature / Industry standard
Very tasty!
Slide 9
Slide 9 text
What I dislike about React
Slide 10
Slide 10 text
What I dislike about React
No official style-guides
No official libraries - 200 routers, 100 state management libs…
TypeScript ? eh? Flow? Maybe.Just.Nothing ?
Episode III: Angular DI
@Injectable()
class HeroService {}
constructor injection
Slide 24
Slide 24 text
Episode III: React DI
React.createContext(value)
Provider
Consumer
Provider
Consumer
Slide 25
Slide 25 text
Episode III: Angular DI without Angular
Injection-js (4kb)
Slide 26
Slide 26 text
@martin_hotell/rea-di (1.6kb)
Episode III: Angular DI with React
DEMO
Slide 27
Slide 27 text
Episode IV
A new State management hope
Slide 28
Slide 28 text
Episode IV: Angular vs React State
@Component()
class CounterComponent {
count = 0
after = 3
}
@Injectable()
class CounterService {
count = 0
after = 3
}
class Counter extends Component {
state = {count:0}
}
Slide 29
Slide 29 text
Episode IV: Stateful services in React
import {Stateful, Injectable} from ‘@martin_hotell/rea-di’
@Injectable()
class Service extends Stateful {
state: T
}
Episode VIII: Angular Schematics
- ng new
- scaffold new app
- ng add
- add 3rd party library and setup
- ng upgrade
- update core libraries
- ng generate
- generate.modify file based on
schematic
ng-new
ng-add
upgrade
schematics
Slide 41
Slide 41 text
Episode VIII: Just Schematics
yarn schematics :
@angular-devkit/schematics-cli
@martin_hotell/my-schematics
component
functional-component
hoc
render-prop-component
hook
Slide 42
Slide 42 text
Episode VIII: Just Schematics
schematics @martin_hotell/my-schematics:component ./heroes/hero
/heroes/hero.tsx ===> class Hero extends Component { }
Slide 43
Slide 43 text
Episode IX
??? WebComponents ???
Slide 44
Slide 44 text
Episode IX: WebComponents
- Angular Elements - SkateJS
Slide 45
Slide 45 text
Summary
Leverage the best parts of Angular within React Apps
+ type safety
+ common style guides / patterns
+ robust Dependency Injection
+ Reactivity via Observables
+ CLI / productivity / refactoring / updates
= Enterprise Ready