ngx-cacheable
Advanced tools
Comparing version 1.1.2 to 1.1.3
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>( | ||
( | ||
@@ -13,3 +13,3 @@ propertyDescriptor, | ||
pendingCachePairs, | ||
cacheConfig: ICacheConfig | ||
cacheConfig | ||
) => { | ||
@@ -16,0 +16,0 @@ /** |
@@ -33,8 +33,2 @@ import { Observable } from 'rxjs'; | ||
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; | ||
} |
@@ -17,3 +17,3 @@ import { ICacheBusterConfig } from './ICacheBusterConfig'; | ||
export const makeCacheableDecorator = <T>( | ||
export const makeCacheableDecorator = <T, K extends ICacheConfig = ICacheConfig>( | ||
decorate: ( | ||
@@ -24,6 +24,6 @@ propertyDescriptor: TypedPropertyDescriptor<ICacheable<T>>, | ||
pendingCachePairs: Array<ICachePair<T>>, | ||
cacheConfig: ICacheConfig | ||
cacheConfig: K | ||
) => void | ||
) => { | ||
return function Cacheable(cacheConfig?: ICacheConfig) { | ||
return function Cacheable(cacheConfig?: K) { | ||
return function( | ||
@@ -43,3 +43,3 @@ _target: Object, | ||
pendingCachePairs, | ||
cacheConfig ? cacheConfig : ({} as ICacheConfig) | ||
cacheConfig ? cacheConfig : ({} as K) | ||
); | ||
@@ -46,0 +46,0 @@ } |
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>>; |
@@ -32,7 +32,2 @@ import { Observable } from 'rxjs'; | ||
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,3 +8,3 @@ import { ICacheBusterConfig } from './ICacheBusterConfig'; | ||
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>>; |
{ | ||
"name": "ngx-cacheable", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Rx Observable cache decorator", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -27,3 +27,3 @@ import { empty, merge } from 'rxjs'; | ||
pendingCachePairs, | ||
cacheConfig: ICacheConfig | ||
cacheConfig | ||
) => { | ||
@@ -30,0 +30,0 @@ /** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
186395
53
3316