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

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…

Contents