Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
switchMap(data => (isSuccess(data) ? f(data.value) : of(data)));
public render() {
const { data } = this.props;
return (
{isPending(data) && this.renderPending()}
{isSuccess(data) && this.renderSuccess(data.value)}
{isFailure(data) && this.renderFailure(data.error)}
);
}
switchMap(data => (isSuccess(data) ? this._getAllValues$ : of(data))),
distinctUntilChanged(),
tap(value => {
if (isSuccess(value)) {
this.cache.set(key, value);
}
}),
);
tap(data => isSuccess(data) && f(data.value));
map(data => data.filter(item => isSuccess(item))),
map(array.sequence(remoteData)),
get(key: string, get: () => LiveData): LiveData {
let sharedGetter: Observable> | undefined = this.cachedStreams.get(key);
if (!isNotNullable(sharedGetter)) {
const hasValue = this.cache.has(key);
const cachedValue = this.cache.getValue(key);
const valueIsResolved = isNotNullable(cachedValue) && isSuccess(cachedValue);
if (hasValue && valueIsResolved) {
return this.cache.get(key);
}
sharedGetter = new Observable>(observer => {
const getterSubscription = get().subscribe(value => {
this.cache.set(key, value);
});
const cacheSubscription = this.cache.get(key).subscribe(value => {
observer.next(value);
});
return () => {
getterSubscription.unsubscribe();
cacheSubscription.unsubscribe();