Skip to content

Commit c2042cd

Browse files
author
nebarf
committed
Align codebase to generics naming styleguide
1 parent 5e8a363 commit c2042cd

13 files changed

+50
-42
lines changed

src/cache/http-cache-store.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ export interface HttpCacheStore {
44
/**
55
* Gets the cached entry for the given identifier.
66
*/
7-
get<T>(identifier: string): HttpCacheEntry<T> | undefined;
7+
get<HttpResponseT>(identifier: string): HttpCacheEntry<HttpResponseT> | undefined;
88

99
/**
1010
* Stores the entry.
1111
*/
12-
put<T>(identifier: string, entry: HttpCacheEntry<T>): () => void;
12+
put<HttpResponseT>(identifier: string, entry: HttpCacheEntry<HttpResponseT>): () => void;
1313

1414
/**
1515
* Determines if the entry is in the store.

src/cache/http-in-memory-cache-store.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ export class HttpInMemoryCacheStore implements HttpCacheStore {
1111
/**
1212
* @inheritdoc
1313
*/
14-
get<T>(identifier: string): HttpCacheEntry<T> | undefined {
15-
return this.store.get(identifier) as HttpCacheEntry<T>;
14+
get<HttpResponseT>(identifier: string): HttpCacheEntry<HttpResponseT> | undefined {
15+
return this.store.get(identifier) as HttpCacheEntry<HttpResponseT>;
1616
}
1717

1818
/**
1919
* @inheritdoc
2020
*/
21-
put<T>(identifier: string, entry: HttpCacheEntry<T>): () => void {
21+
put<HttpResponseT>(identifier: string, entry: HttpCacheEntry<HttpResponseT>): () => void {
2222
this.store.set(identifier, entry);
2323
return () => this.delete(identifier);
2424
}

src/cache/prefix-decorator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ export class HttpCacheStorePrefixDecorator implements HttpCacheStore {
3434
/**
3535
* @inheritdoc
3636
*/
37-
get<T>(entryIdentifier: string): HttpCacheEntry<T> | undefined {
37+
get<HttpResponseT>(entryIdentifier: string): HttpCacheEntry<HttpResponseT> | undefined {
3838
const prefixedIdentifier = this.getPrefixedIdentifier(entryIdentifier);
3939
return this.store.get(prefixedIdentifier);
4040
}
4141

4242
/**
4343
* @inheritdoc
4444
*/
45-
put<T>(entryIdentifier: string, entry: HttpCacheEntry<T>): () => void {
45+
put<HttpResponseT>(entryIdentifier: string, entry: HttpCacheEntry<HttpResponseT>): () => void {
4646
const prefixedIdentifier = this.getPrefixedIdentifier(entryIdentifier);
4747
return this.store.put(prefixedIdentifier, entry);
4848
}

src/cache/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export interface HttpCacheEntry<T> {
1+
export interface HttpCacheEntry<HttpResponseT> {
22
/**
33
* The identifier for the cached entry.
44
*/
@@ -7,7 +7,7 @@ export interface HttpCacheEntry<T> {
77
/**
88
* The cached parsed reponse for the remote call.
99
*/
10-
response: T;
10+
response: HttpResponseT;
1111

1212
/**
1313
* Keeps track of the Date the entry was cached.

src/config/response-parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export function httpResponseParser<HttpResponse>(res: Response): Promise<HttpResponse> {
1+
export function httpResponseParser<HttpResponseT>(res: Response): Promise<HttpResponseT> {
22
return res.json();
33
}

src/events-manager/event-bus.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ export class EventBus {
1414
/**
1515
* Gets the set of subscriptions associated with the provided http event class type.
1616
*/
17-
private _ensureEventSubscriptionInit<T>(
18-
httpEventType: HttpEventClassType<T>
19-
): Set<HttpEventHandler<T>> {
17+
private _ensureEventSubscriptionInit<PayloadT>(
18+
httpEventType: HttpEventClassType<PayloadT>
19+
): Set<HttpEventHandler<PayloadT>> {
2020
const currentEventSubscriptions = this._subscriptions.get(httpEventType);
2121
if (currentEventSubscriptions) {
2222
return currentEventSubscriptions;
2323
}
2424

25-
const newEventSubscriptionsSet = new Set<HttpEventHandler<T>>();
25+
const newEventSubscriptionsSet = new Set<HttpEventHandler<PayloadT>>();
2626
this._subscriptions.set(httpEventType, newEventSubscriptionsSet);
2727
return newEventSubscriptionsSet;
2828
}
@@ -31,7 +31,7 @@ export class EventBus {
3131
* Gets the number of subscriptions for the given event.
3232
* @param {*} eventName
3333
*/
34-
getEventSubscriptionsCount<T>(httpEventType: HttpEventClassType<T>): number {
34+
getEventSubscriptionsCount<PayloadT>(httpEventType: HttpEventClassType<PayloadT>): number {
3535
const eventSubscriptions = this._subscriptions.get(httpEventType);
3636
return eventSubscriptions ? eventSubscriptions.size : 0;
3737
}
@@ -41,7 +41,10 @@ export class EventBus {
4141
* @param {*} eventName
4242
* @param {*} handler
4343
*/
44-
subscribe<T>(httpEventType: HttpEventClassType<T>, handler: HttpEventHandler<T>): () => void {
44+
subscribe<PayloadT>(
45+
httpEventType: HttpEventClassType<PayloadT>,
46+
handler: HttpEventHandler<PayloadT>
47+
): () => void {
4548
const eventSubscriptions = this._ensureEventSubscriptionInit(httpEventType);
4649
eventSubscriptions.add(handler);
4750

@@ -53,8 +56,8 @@ export class EventBus {
5356
* @param {*} eventName
5457
* @param {*} payload
5558
*/
56-
publish<T>(httpEvent: HttpEvent<T>): void {
57-
const httpEventType = httpEvent.constructor as HttpEventClassType<T>;
59+
publish<PayloadT>(httpEvent: HttpEvent<PayloadT>): void {
60+
const httpEventType = httpEvent.constructor as HttpEventClassType<PayloadT>;
5861
// Do nothing if the subscriptions set for the given event is empty.
5962
const eventHandlers = this._subscriptions.get(httpEventType);
6063
if (!eventHandlers || eventHandlers.size === 0) {
@@ -69,7 +72,10 @@ export class EventBus {
6972
* @param {*} eventName
7073
* @param {*} subscription
7174
*/
72-
unsubscribe<T>(httpEventType: HttpEventClassType<T>, handler: HttpEventHandler<T>): void {
75+
unsubscribe<PayloadT>(
76+
httpEventType: HttpEventClassType<PayloadT>,
77+
handler: HttpEventHandler<PayloadT>
78+
): void {
7379
const eventSubscriptionsSet = this._subscriptions.get(httpEventType);
7480
if (!eventSubscriptionsSet || eventSubscriptionsSet.size === 0) {
7581
return;
@@ -86,7 +92,7 @@ export class EventBus {
8692
* Detaches all subscriptions for the given event.
8793
* @param {*} eventName
8894
*/
89-
detachEventSubscriptions<T>(httpEventType: HttpEventClassType<T>): void {
95+
detachEventSubscriptions<PayloadT>(httpEventType: HttpEventClassType<PayloadT>): void {
9096
if (!this._subscriptions.has(httpEventType)) {
9197
return;
9298
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export abstract class HttpEvent<T> {
1+
export abstract class HttpEvent<PayloadT> {
22
/**
33
* A payload.
44
*/
5-
abstract payload: T;
5+
abstract payload: PayloadT;
66
}

src/events-manager/events/request-started-event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { HttpRequest } from '../../client';
22
import { HttpEvent } from './http-event';
33

4-
export class RequestStartedEvent<HttpRequestBodyT = unknown> extends HttpEvent<
4+
export class RequestStartedEvent<HttpRequestBodyT> extends HttpEvent<
55
HttpRequest<HttpRequestBodyT>
66
> {
77
/**

src/events-manager/events/request-succeded-event.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
import { HttpRequest } from '../../client';
22
import { HttpEvent } from './http-event';
33

4-
export interface RequestSuccededEventPayload<T, U> {
5-
request: HttpRequest<U>;
6-
response: T;
4+
export interface RequestSuccededEventPayload<HttpResponseT, HttpRequestBodyT> {
5+
request: HttpRequest<HttpRequestBodyT>;
6+
response: HttpResponseT;
77
}
88

9-
export class RequestSuccededEvent<T, U> extends HttpEvent<RequestSuccededEventPayload<T, U>> {
9+
export class RequestSuccededEvent<HttpResponseT, HttpRequestBodyT> extends HttpEvent<
10+
RequestSuccededEventPayload<HttpResponseT, HttpRequestBodyT>
11+
> {
1012
/**
1113
* @inheritdoc
1214
*/
13-
payload: RequestSuccededEventPayload<T, U>;
15+
payload: RequestSuccededEventPayload<HttpResponseT, HttpRequestBodyT>;
1416

15-
constructor(payload: RequestSuccededEventPayload<T, U>) {
17+
constructor(payload: RequestSuccededEventPayload<HttpResponseT, HttpRequestBodyT>) {
1618
super();
1719
this.payload = payload;
1820
}

src/events-manager/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export enum HttpEventIdentifier {
66
RequestErrored = 'RequestErrored',
77
}
88

9-
export type HttpEventHandler<T> = (payload: T) => void;
9+
export type HttpEventHandler<PayloadT> = (payload: PayloadT) => void;
1010

11-
export type HttpEventClassType<T> = new (...args: unknown[]) => HttpEvent<T>;
11+
export type HttpEventClassType<PayloadT> = new (...args: unknown[]) => HttpEvent<PayloadT>;

0 commit comments

Comments
 (0)