Skip to content

Commit

Permalink
test: 💍 refactor specs
Browse files Browse the repository at this point in the history
  • Loading branch information
NetanelBasal committed Jun 7, 2021
1 parent 6e42a8f commit a602834
Show file tree
Hide file tree
Showing 27 changed files with 22,095 additions and 18,878 deletions.
64 changes: 2 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,66 +141,6 @@ HttpCacheInterceptorModule.forRoot({
});
```

#### `parameterCodec`

Define the `HttpParameterCodec` implementation if you need a different parameter encoder.

Example of custom implementation that uses `encodeURIComponent`:

<!-- prettier-ignore -->
```ts
import { HttpCacheInterceptorModule, useHttpCacheLocalStorage } from '@ngneat/cashew';
import { HttpParameterCodec } from '@angular/common/http';

class CustomHttpParameterCodec implements HttpParameterCodec {
encodeKey(key: string): string {
return encodeURIComponent(key);
}
encodeValue(value: string): string {
return encodeURIComponent(value);
}
decodeKey(key: string): string {
return decodeURIComponent(key);
}
decodeValue(value: string): string {
return decodeURIComponent(value);
}
}

@NgModule({
imports: [
HttpClientModule,
HttpCacheInterceptorModule.forRoot({ parameterCodec: new CustomHttpParameterCodec() })
],
providers: [useHttpCacheLocalStorage],
bootstrap: [AppComponent]
})
export class AppModule {}
```

or per request:

```ts
class CustomHttpParameterCodec implements HttpParameterCodec {
// ...
}

@Injectable()
export class UsersService {
constructor(private http: HttpClient) {}

getUsers() {
return this.http.get(
'api/users',
withCache({
parameterCodec$: new CustomHttpParameterCodec(),
...
})
);
}
}
```

## API

### WithCache
Expand Down Expand Up @@ -305,15 +245,15 @@ abstract class HttpCacheStorage {

```ts
export abstract class KeySerializer {
abstract serialize(request: HttpCacheRequest): string;
abstract serialize(request: HttpRequest): string;
}
```

- `HttpCacheGuard` - When using the **`implicit`** strategy it first verifies that `canActivate` is truthy:

```ts
export abstract class HttpCacheGuard {
abstract canActivate(request: HttpCacheRequest): boolean;
abstract canActivate(request: HttpCacheHttpRequestRequest): boolean;
}
```

Expand Down
Loading

0 comments on commit a602834

Please sign in to comment.