Skip to content

Commit

Permalink
Release 1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Angel Nikolov committed Mar 19, 2019
1 parent df4c654 commit 628366e
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 27 deletions.
6 changes: 3 additions & 3 deletions cacheable.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { empty, merge, Observable, of, Subject } from 'rxjs';
import { delay, finalize, shareReplay, tap } from 'rxjs/operators';
import { DEFAULT_CACHE_RESOLVER, makeCacheableDecorator } from './common';
import { ICacheConfig } from './common/ICacheConfig';
import { IObservableCacheConfig } from './common/IObservableCacheConfig';
export const globalCacheBusterNotifier = new Subject<void>();

export const Cacheable = makeCacheableDecorator<Observable<any>>(
export const Cacheable = makeCacheableDecorator<Observable<any>, IObservableCacheConfig>(
(
propertyDescriptor,
oldMethod,
cachePairs,
pendingCachePairs,
cacheConfig: ICacheConfig
cacheConfig
) => {
/**
* subscribe to the globalCacheBuster
Expand Down
6 changes: 0 additions & 6 deletions common/ICacheConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,4 @@ export interface ICacheConfig {
* pass an Observable upon whose emission all caches will be busted
*/
cacheBusterObserver?: Observable<any>;

/**
* cache will be resolved asynchronously - an extra change detection pass will be made by
* @description should cache be resolved asynchronously? - helps with declarative forms and two-way databinding via ngModel
*/
async?: boolean;
}
9 changes: 9 additions & 0 deletions common/IObservableCacheConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ICacheConfig } from './ICacheConfig';

export interface IObservableCacheConfig extends ICacheConfig {
/**
* cache will be resolved asynchronously - an extra change detection pass will be made by
* @description should cache be resolved asynchronously? - helps with declarative forms and two-way databinding via ngModel
*/
async?: boolean;
}
8 changes: 4 additions & 4 deletions common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ export type IShouldCacheDecider = (response: any) => boolean;

export type ICacheable<T> = (...args) => T;

export const makeCacheableDecorator = <T>(
export const makeCacheableDecorator = <T, K extends ICacheConfig = ICacheConfig>(
decorate: (
propertyDescriptor: TypedPropertyDescriptor<ICacheable<T>>,
oldMethod: ICacheable<T>,
cachePairs: Array<ICachePair<any>>,
pendingCachePairs: Array<ICachePair<T>>,
cacheConfig: ICacheConfig
cacheConfig: K
) => void
) => {
return function Cacheable(cacheConfig?: ICacheConfig) {
return function Cacheable(cacheConfig?: K) {
return function(
_target: Object,
_propertyKey: string,
Expand All @@ -38,7 +38,7 @@ export const makeCacheableDecorator = <T>(
oldMethod,
cachePairs,
pendingCachePairs,
cacheConfig ? cacheConfig : ({} as ICacheConfig)
cacheConfig ? cacheConfig : ({} as K)
);
}
return propertyDescriptor;
Expand Down
4 changes: 2 additions & 2 deletions dist/cacheable.decorator.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Observable, Subject } from 'rxjs';
import { ICacheConfig } from './common/ICacheConfig';
import { IObservableCacheConfig } from './common/IObservableCacheConfig';
export declare const globalCacheBusterNotifier: Subject<void>;
export declare const Cacheable: (cacheConfig?: ICacheConfig) => (_target: Object, _propertyKey: string, propertyDescriptor: TypedPropertyDescriptor<(...args: any[]) => Observable<any>>) => TypedPropertyDescriptor<(...args: any[]) => Observable<any>>;
export declare const Cacheable: (cacheConfig?: IObservableCacheConfig) => (_target: Object, _propertyKey: string, propertyDescriptor: TypedPropertyDescriptor<(...args: any[]) => Observable<any>>) => TypedPropertyDescriptor<(...args: any[]) => Observable<any>>;
2 changes: 1 addition & 1 deletion dist/cacheable.decorator.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions dist/common/ICacheConfig.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,4 @@ export interface ICacheConfig {
* pass an Observable upon whose emission all caches will be busted
*/
cacheBusterObserver?: Observable<any>;
/**
* cache will be resolved asynchronously - an extra change detection pass will be made by
* @description should cache be resolved asynchronously? - helps with declarative forms and two-way databinding via ngModel
*/
async?: boolean;
}
8 changes: 8 additions & 0 deletions dist/common/IObservableCacheConfig.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ICacheConfig } from './ICacheConfig';
export interface IObservableCacheConfig extends ICacheConfig {
/**
* cache will be resolved asynchronously - an extra change detection pass will be made by
* @description should cache be resolved asynchronously? - helps with declarative forms and two-way databinding via ngModel
*/
async?: boolean;
}
3 changes: 3 additions & 0 deletions dist/common/IObservableCacheConfig.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/common/IObservableCacheConfig.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/common/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export declare const DEFAULT_CACHE_RESOLVER: (oldParams: any, newParams: any) =>
export declare type ICacheRequestResolver = (oldParameters: Array<any>, newParameters: Array<any>) => boolean;
export declare type IShouldCacheDecider = (response: any) => boolean;
export declare type ICacheable<T> = (...args) => T;
export declare const makeCacheableDecorator: <T>(decorate: (propertyDescriptor: TypedPropertyDescriptor<ICacheable<T>>, oldMethod: ICacheable<T>, cachePairs: ICachePair<any>[], pendingCachePairs: ICachePair<T>[], cacheConfig: ICacheConfig) => void) => (cacheConfig?: ICacheConfig) => (_target: Object, _propertyKey: string, propertyDescriptor: TypedPropertyDescriptor<ICacheable<T>>) => TypedPropertyDescriptor<ICacheable<T>>;
export declare const makeCacheableDecorator: <T, K extends ICacheConfig = ICacheConfig>(decorate: (propertyDescriptor: TypedPropertyDescriptor<ICacheable<T>>, oldMethod: ICacheable<T>, cachePairs: ICachePair<any>[], pendingCachePairs: ICachePair<T>[], cacheConfig: K) => void) => (cacheConfig?: K) => (_target: Object, _propertyKey: string, propertyDescriptor: TypedPropertyDescriptor<ICacheable<T>>) => TypedPropertyDescriptor<ICacheable<T>>;
export declare const makeCacheBusterDecorator: <T>(decorate: (propertyDescriptor: TypedPropertyDescriptor<ICacheable<T>>, oldMethod: ICacheable<T>, cacheBusterConfig: ICacheBusterConfig) => void) => (cacheBusterConfig?: ICacheBusterConfig) => (_target: Object, _propertyKey: string, propertyDescriptor: TypedPropertyDescriptor<ICacheable<T>>) => TypedPropertyDescriptor<ICacheable<T>>;
2 changes: 1 addition & 1 deletion dist/common/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/promise.cacheable.decorator.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 628366e

Please sign in to comment.