Skip to content

Commit

Permalink
feat(): deprecate forRoot and remove galleryService and IdValidatorSe…
Browse files Browse the repository at this point in the history
…rvice in favour of providedIn: 'root' #144
  • Loading branch information
Ks89 committed Oct 15, 2018
1 parent 5ee047d commit 1ab263b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import { DIRECTIVES } from './directives/directives';
import { COMPONENTS, ModalGalleryComponent, CarouselComponent } from './components/components';
import { KEYBOARD_CONFIGURATION, KeyboardService } from './services/keyboard.service';
import { KeyboardServiceConfig } from './model/keyboard-service-config.interface';
import { GalleryService } from './services/gallery.service';
import { IdValidatorService } from './services/id-validator.service';

/**
* Module with `forRoot` method to import it in the root module of your application.
Expand All @@ -41,6 +39,12 @@ import { IdValidatorService } from './services/id-validator.service';
exports: [ModalGalleryComponent, CarouselComponent]
})
export class GalleryModule {
/**
* Importing with '.forRoot()' is no longer necessary, you can simply import the module.
* Will be removed in 8.0.0.
*
* @deprecated 7.0.0
*/
static forRoot(config?: KeyboardServiceConfig): ModuleWithProviders {
return {
ngModule: GalleryModule,
Expand All @@ -53,14 +57,6 @@ export class GalleryModule {
provide: KeyboardService,
useFactory: setupKeyboardService,
deps: [KEYBOARD_CONFIGURATION]
},
{
provide: GalleryService,
useFactory: setupGalleryService
},
{
provide: IdValidatorService,
useFactory: setupIdValidatorService
}
]
};
Expand All @@ -75,11 +71,3 @@ export class GalleryModule {
export function setupKeyboardService(injector: KeyboardServiceConfig): KeyboardService {
return new KeyboardService(injector);
}

export function setupGalleryService(): GalleryService {
return new GalleryService();
}

export function setupIdValidatorService(): IdValidatorService {
return new IdValidatorService();
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface InternalGalleryPayload {
image?: Image;
}

@Injectable()
@Injectable({ providedIn: 'root' })
export class GalleryService {
navigate: EventEmitter<InternalGalleryPayload> = new EventEmitter<InternalGalleryPayload>();
close: EventEmitter<number> = new EventEmitter<number>();
Expand Down Expand Up @@ -64,6 +64,11 @@ export class GalleryService {
this.close.emit(galleryId);
}

/**
* Service to update an image with a new object
*
* @since 6.3.0
*/
updateGallery(galleryId: number | undefined, index: number, image: Image): void {
if (galleryId === undefined || galleryId < 0 || index < 0) {
throw new Error('Cannot update gallery via GalleryService with either index<0 or galleryId<0 or galleryId===undefined');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Injectable } from '@angular/core';
/**
* Service to check if the provided id is unique
*/
@Injectable()
@Injectable({ providedIn: 'root' })
export class IdValidatorService {
ids = new Map();

Expand Down

0 comments on commit 1ab263b

Please sign in to comment.