Skip to content
This repository has been archived by the owner on Jul 29, 2023. It is now read-only.

Commit

Permalink
refactor: suffix public entities with ngx
Browse files Browse the repository at this point in the history
To better represent that the entities are provided by the library, I prepended them with `ngx`.
  • Loading branch information
chernodub committed Nov 4, 2022
1 parent 4d733a9 commit eea2112
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 33 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ npm i ngx-lss

## Setting up

1. Import `LocalStorageModule` to root module of your app
1. Import `NgxLocalStorageModule` to root module of your app

```typescript
import { LocalStorageModule } from 'ngx-lss';
import { NgxLocalStorageModule } from 'ngx-lss';

@NgModule({
// ...
imports: [
// ...
LocalStorageModule,
NgxLocalStorageModule,
]
})
export class AppModule { }
Expand All @@ -45,7 +45,7 @@ npm i ngx-lss

```typescript
import { Component } from '@angular/core';
import { LocalStorageService } from 'ngx-lss';
import { NgxLocalStorageService } from 'ngx-lss';

@Component({
selector: 'app-root',
Expand All @@ -54,7 +54,7 @@ npm i ngx-lss
})
export class AppComponent {
public constructor(
private readonly localStorageService: LocalStorageService,
private readonly NgxLocalStorageService: NgxLocalStorageService,
) {
// ...
}
Expand All @@ -70,7 +70,7 @@ npm i ngx-lss

```ts
import { Injectable } from '@angular/core';
import { LocalStorageService } from 'ngx-lss';
import { NgxLocalStorageService } from 'ngx-lss';
import { map, Observable } from 'rxjs';

import { UserSecret } from '../models/user-secret';
Expand All @@ -84,7 +84,7 @@ export class UserSecretStorageService {
public readonly currentSecret$: Observable<UserSecret | null>;

public constructor(
private readonly storageService: LocalStorageService,
private readonly storageService: NgxLocalStorageService,
) {
this.currentSecret$ = this.storageService.get<UserSecret>(USER_SECRET_STORAGE_KEY);
}
Expand All @@ -110,7 +110,7 @@ export class UserSecretStorageService {

```typescript
import { Component } from '@angular/core';
import { LocalStorageService } from 'ngx-lss';
import { NgxLocalStorageService } from 'ngx-lss';

const COUNTER_KEY = 'counter';

Expand All @@ -125,7 +125,7 @@ export class AppComponent {
public readonly counter$: Observable<number | null>;

public constructor(
private readonly storage: LocalStorageService,
private readonly storage: NgxLocalStorageService,
) {
this.counter$ = this.storage.get<number>(COUNTER_KEY);
}
Expand Down
16 changes: 0 additions & 16 deletions projects/ngx-lss/src/lib/local-storage.module.ts

This file was deleted.

12 changes: 12 additions & 0 deletions projects/ngx-lss/src/lib/ngx-local-storage.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { NgxLocalStorageService } from './ngx-local-storage.service';

/** Module providing local storage adapter service. */
@NgModule({
declarations: [],
imports: [CommonModule],
providers: [NgxLocalStorageService],
})
export class NgxLocalStorageModule { }
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { fakeAsync, flush } from '@angular/core/testing';
import { createServiceFactory, SpectatorService } from '@ngneat/spectator';
import { Observer, Subscription } from 'rxjs';
import { LocalStorageService } from './local-storage.service';

import { NgxLocalStorageService } from './ngx-local-storage.service';

/** Creates observer spy object. */
export function createObserverSpy<T>(): jasmine.SpyObj<Observer<T>> {
return jasmine.createSpyObj('observer', ['next', 'error', 'complete']);
}

describe('LocalStorageService', () => {
let spectator: SpectatorService<LocalStorageService>;
describe('NgxLocalStorageService', () => {
let spectator: SpectatorService<NgxLocalStorageService>;
let subs: Subscription[];

const createService = createServiceFactory({
service: LocalStorageService,
service: NgxLocalStorageService,
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { WINDOW } from './utils/window-token';
* Angular adapter for the local storage.
*/
@Injectable()
export class LocalStorageService {
export class NgxLocalStorageService {
/** Emits the key of the value changed in the local storage. */
private readonly valueChangedSubject = new Subject<string>();

Expand Down
4 changes: 2 additions & 2 deletions projects/ngx-lss/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
* Public API Surface of ngx-lss
*/

export * from './lib/local-storage.service';
export * from './lib/local-storage.module';
export * from './lib/ngx-local-storage.service';
export * from './lib/ngx-local-storage.module';
3 changes: 2 additions & 1 deletion projects/ngx-lss/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing';

declare const require: {
Expand All @@ -23,5 +23,6 @@ getTestBed().initTestEnvironment(

// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);

// And load the modules.
context.keys().forEach(context);

0 comments on commit eea2112

Please sign in to comment.