Skip to content

Instantly share code, notes, and snippets.

View davidecavaliere's full-sized avatar
🏠
Working from home

Davide Cavaliere davidecavaliere

🏠
Working from home
View GitHub Profile
export function Cache(options: CacheOptions) {
let lastCallArguments: any[] = [];
return (target, propertyKey: string, descriptor) => {
Reflect.metadata(CacheMetadata, options)(target);
setTimeout(() => {
this.$log.d('starting subscriber');
this.userService.findAll(1).subscribe((data) => {
this.$log.d('starting subscribed');
this.$log.d(data);
this.users = data;
})
}, 0);
setTimeout(() => {
[…]
 third subscriber 3 sec later, ttl expired. shoult hit the endpoint
 arguments are
 [1]
 argsNotChanged
 true
 this actually hit the endpoint
 starting subscribed
 {page: 1, per_page: 6, total: 12, total_pages: 2…}
 first subscribed