From the course: Building Native Mobile Apps with NativeScript and Angular 2
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Barrels - JavaScript Tutorial
From the course: Building Native Mobile Apps with NativeScript and Angular 2
Barrels
- [Narrator] One convenient trick we can implement with modules that are filed in the same folder is to use something called a barrel. And it is used to surface the exports of all modules that are in the folder using an index file. Since we'll have several services in our app, I'm going to add a user service and show you how we can use a barrel to export it. In our services folder, we're gonna create a new file called userservice.ts. And let's use an angular snippet to create a service and that's gonna be a-service. I'm gonna call this service UserService. We'll add some logic here a bit later. Let's also create a barrel. And this is the index.ts file that lives in a folder and exports any contents that you want rolled up. Our index.ts file exports everything from the backlog service and from the user service modules. So we're gonna export everything from the local backlog service. And I'm gonna copy and paste that. We're gonna also export everything from the user service. Let's save…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Components5m
-
Component template2m 58s
-
Component styles2m 25s
-
Template variables3m 41s
-
Handling Listview tap2m 33s
-
Backlog item template4m 9s
-
Nested layouts4m 50s
-
Directives: ngIf6m 52s
-
Directives: ngFor3m 48s
-
Dependency injection: Part 14m 26s
-
Dependency injection: Part 26m 31s
-
Application lifecycle9m 56s
-
Modules3m 40s
-
Barrels2m 6s
-
-
-
-
-