Skip to content

Commit 1667a8e

Browse files
IdleService move out of app.component (#242)
* feat(): add ScullyModule * feat(): add ScullyContentModule to ship individual pieces * improvement(idleservice and componetsmodule): get gird of injecting idleService, and better name This PR gets rid of the compentsModule name in favor for ScullyLibModule. Also it removed the need to add the idleService to app.component. BREAKING CHANGE: componentsModule is renamed * refactor(remove stray nguniversal files): remove some stray ngUniversal files * fix(appp.module): put browsermodule back in Co-authored-by: Stewan Silva <oi@stewan.io>
1 parent 62cd801 commit 1667a8e

File tree

12 files changed

+128
-87
lines changed

12 files changed

+128
-87
lines changed

projects/sampleBlog/src/app/app-routing.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {NgModule} from '@angular/core';
2-
import {Routes, RouterModule} from '@angular/router';
2+
import {RouterModule, Routes} from '@angular/router';
33

44
const routes: Routes = [
55
{

projects/sampleBlog/src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ export class AppComponent {
1212
: isScullyGenerated()
1313
? 'Loaded from static HTML'
1414
: 'SPA mode';
15-
constructor(private idle: IdleMonitorService) {}
15+
constructor() {}
1616
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import {HttpClientModule} from '@angular/common/http';
22
import {NgModule} from '@angular/core';
33
import {BrowserModule} from '@angular/platform-browser';
4+
import {ScullyLibModule} from '@scullyio/ng-lib';
45
import {AppRoutingModule} from './app-routing.module';
56
import {AppComponent} from './app.component';
67

78
@NgModule({
89
declarations: [AppComponent],
9-
imports: [HttpClientModule, BrowserModule.withServerTransition({appId: 'serverApp'}), AppRoutingModule],
10+
imports: [BrowserModule, HttpClientModule, AppRoutingModule, ScullyLibModule],
1011
bootstrap: [AppComponent],
1112
})
1213
export class AppModule {}

projects/sampleBlog/src/app/app.server.module.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {CommonModule} from '@angular/common';
22
import {NgModule} from '@angular/core';
3-
import {ComponentsModule} from '@scullyio/ng-lib';
3+
import {ScullyLibModule} from '@scullyio/ng-lib';
4+
import {BlogListComponent} from './blog-list/blog-list.component';
45
import {BlogRoutingModule} from './blog-routing.module';
56
import {BlogComponent} from './blog.component';
6-
import {BlogListComponent} from './blog-list/blog-list.component';
77

88
@NgModule({
99
declarations: [BlogComponent, BlogListComponent],
10-
imports: [CommonModule, BlogRoutingModule, ComponentsModule],
10+
imports: [CommonModule, BlogRoutingModule, ScullyLibModule],
1111
})
1212
export class BlogModule {}

projects/sampleBlog/src/main.server.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {NgModule} from '@angular/core';
2-
import {ScullyContentComponent} from './scully-content/scully-content.component';
2+
import {ScullyContentComponent} from './scully-content.component';
33

44
@NgModule({
55
declarations: [ScullyContentComponent],
66
exports: [ScullyContentComponent],
77
})
8-
export class ComponentsModule {}
8+
export class ScullyContentModule {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {NgModule} from '@angular/core';
2+
import {IdleMonitorService} from './idleMonitor/idle-monitor.service';
3+
import {ScullyContentModule} from './scully-content/scully-content.module';
4+
5+
@NgModule({
6+
imports: [ScullyContentModule],
7+
exports: [ScullyContentModule],
8+
})
9+
export class ScullyLibModule {
10+
/**
11+
* We use a little trick to get a working idle-service.
12+
* First, we separate out the component in a separate module to prevent a circulair injection
13+
* second we create a constuctor that activates the IdleMonitorService. as that is provided for 'root'
14+
* there will be only 1 instance in our app.
15+
* We don't need forRoot, as we are not configuring anything in here.
16+
*/
17+
constructor(private idle: IdleMonitorService) {}
18+
}

projects/scullyio/ng-lib/src/public-api.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
* Public API Surface of ng-lib
33
*/
44

5-
export * from './lib/components.module';
65
export * from './lib/idleMonitor/idle-monitor.service';
7-
export * from './lib/transfer-state/transfer-state.service';
86
export * from './lib/route-service/scully-routes.service';
97
export * from './lib/scully-content/scully-content.component';
8+
export * from './lib/scully-content/scully-content.module';
9+
export * from './lib/scully-lib.module';
10+
export * from './lib/transfer-state/transfer-state.service';
1011
export * from './lib/utils/isScully';
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {CommonModule} from '@angular/common';
22
import {NgModule} from '@angular/core';
3-
import {ComponentsModule} from '@scullyio/ng-lib';
3+
import {ScullyLibModule} from '@scullyio/ng-lib/bundles/scullyio-ng-lib.umd';
44
import {BlogRoutingModule} from './blog-routing.module';
55
import {BlogComponent} from './blog.component';
66

77
@NgModule({
88
declarations: [BlogComponent],
9-
imports: [CommonModule, BlogRoutingModule, ComponentsModule],
9+
imports: [CommonModule, BlogRoutingModule, ScullyLibModule],
1010
})
1111
export class BlogModule {}

0 commit comments

Comments
 (0)