Created
March 10, 2019 10:07
-
-
Save jack-guy/85548b32754b23d1d8c52b60302ddfca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const filterLoggedIn$ = (stream$) => { | |
return stream$.pipe( | |
withLatestFrom(iceCreamAuth$), | |
filter((auth) => auth) | |
) | |
}; | |
const combinedInfoFactory$ = ( | |
iceCreamPreferences$, | |
iceCreamInventory$, | |
iceCreamTemperature$ | |
) => { | |
return combineLatest( | |
iceCreamPreferences$, | |
iceCreamInventory$, | |
iceCreamTemperature$, | |
).pipe( | |
map(([iceCreamPreferences, iceCreamInventory, iceCreamTemperature]) => combineInfo( | |
iceCreamPreferences, | |
iceCreamInventory, | |
iceCreamTemperature | |
)), | |
); | |
}; | |
from(iceCreamIds).pipe( | |
filterLoggedIn$, | |
withLatestFrom(iceCreamVendor$), | |
flatMap(([iceCreamId, iceCreamVendor]) => { | |
if (iceCreamVendor) { | |
return combinedInfoFactory$( | |
iceCreamPreferences$, | |
iceCreamInventory$, | |
iceCreamTemperature$, | |
).pipe( | |
map(([combinedInfo]) => [iceCreamId, combinedInfo]), | |
); | |
} | |
return of([]); | |
}), | |
// ... | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment