Closed crjacinro closed 5 years ago
Hi there. Can you get me some pseudo-code out of the loadApplications
method? Thanks!
Its quite complex because it passes a lot of abstractions in our code.
Here is a snippet
`public loadApplications(membershipStatus: MembershipApplicationStatus, dateRange: DateRange) { this.membershipStatus = membershipStatus; this.dateRange = dateRange; return Observable.create(this.loadApplicationsObservable) }
loadApplicationsObservable = (observer: Observer<Map<string, MembershipApplicationData>>) => {
this.observer = observer;
this.getApplicationsService.getAllApplications(this.membershipStatus, this.dateRange).subscribe(
this.onLoadApplicationsComplete, this.onLoadApplicationsFailed
);
}`
Hmm, this very basic repro works. Can you find something different with it versus your setup?
import { Observable, Observer } from 'rxjs';
import { Cacheable } from './ngx-cacheable';
class Testbed {
@Cacheable()
getData(id: number) {
return Observable.create((observer: Observer<any>)=>{
console.log("accessed from data source")
setTimeout(()=>{
observer.next([1,2,3])
}, 2500);
})
}
}
const testbed = new Testbed();
testbed.getData(1).subscribe(console.log);
testbed.getData(1).subscribe(console.log);
@crjacinro any updates?
hello, still not able to make it work until now.
Is this library only compatible with HTTP observables? I have a custom observable in which i control the execution of next and complete methods.
This is my code.
loadApplicationsWithCache(enumValue, {date: "").subscribe(this.onLoadApiComplete, this.onLoadApiError)
@Cacheable() loadApplicationsWithCache(status: someEnumType, date: someObject) : Observable<Map<string, Data>> { return this.loadApplicationsFromAPI.loadApplications(status, date); }
At first, the actual API is being called. The second invocation emits empty map.