Techniques
Advanced
(for enterprise applications!)
Google Developer Expert
Google Developer Expert
Ask me how to become a:
⭐️ Google Developer Expert ⭐️
@jdjuan
Problem
#1
tsconfig.json
#2
#3
📁
LIFT
Keep your folder
structure maintainable
LOCATE
📁
IDENTIFY
📁
FLAT
📁
7 files per folder
TRY DRY
📁
#4
📦
#5
🐫
What standard should I follow for naming?
Be clear
Don't add meta data
Consider the context
Name a variable that store the maximum inactivity time allowed for a transaction in an online store
transactionTime
transactionInactivityTimeValue
transactionInactivityTimePurchaseProduct
transactionMaxIdleTime
txMaxIdleTime
txMaxIdleMilliseconds
Camel case for variables and functions
Title case for classes and interfaces
Dash case for files and folders
camelCaseForVariablesAndFunctions
dash-case-for-files-and-folders
TitleCaseForClassesAndInterfaces
tinyurl.com/my-vscode
#6
ASYNC
SUBSCRIBE
OR
export class AppComponent {
url = 'https://yesno.wtf/api';
image;
constructor(private http: HttpClient) {
http
.get(this.url)
.pipe(pluck('image'))
.subscribe((image) => (this.image = image));
}
}
app.component.ts
<img [src]="image" alt="">
app.component.html
export class AppComponent {
url = 'https://yesno.wtf/api';
data$;
constructor(private http: HttpClient) {
this.data$ = http.get(this.url);
}
}
app.component.ts
<img [src]="(data$ | async).image">
app.component.html
<div *ngIf="data$ | async as data">
<img [src]="data.image">
</div>
app.component.html
#7
🌎
const routes: Routes = [
{
path: '',
redirectTo: 'dashboard',
pathMatch: 'full',
},
{
path: 'forecast/:id',
loadChildren:
'src/app/forecast/forecast.module#ForecastModule',
},
{
path: 'dashboard',
redirectTo: '/dashboard',
pathMatch: 'full',
},
{
path: 'forecast',
redirectTo: '/forecast',
pathMatch: 'full',
},
{
path: '**',
component: NotFoundComponent,
},
];
#8
⏳
{
path: 'forecast/:id',
loadChildren:
'src/app/forecast/forecast.module#ForecastModule',
}
Lazy Loading
@NgModule({
imports: [
RouterModule.forRoot(routes, {
preloadingStrategy: PreloadAllModules,
}),
],
exports: [RouterModule],
})
app-routing.component.ts
#9
🥶
BACKGROUND_COLORS = ['#A296F7','#A296F7','#A296F7'];
readonly BACKGROUND_COLORS = ['#A296F7','#A296F7','#A296F7'];
#10
🤵🤵🤵🤵🤵🤵
Type Coverage
📝
THANK YOU!
@jdjuan