Dynamically switches between observables in a record based on a key observable. When the key changes, automatically unsubscribes from the previous observable and subscribes to the new one.
const data = { home: homeData$, profile: profileData$, settings: settingsData$};const currentTab$ = createState('home');const currentData$ = withSwitch(data, currentTab$);// When currentTab$ changes, automatically switches to observing the corresponding data observable Copy
const data = { home: homeData$, profile: profileData$, settings: settingsData$};const currentTab$ = createState('home');const currentData$ = withSwitch(data, currentTab$);// When currentTab$ changes, automatically switches to observing the corresponding data observable
Dynamically switches between observables in a record based on a key observable. When the key changes, automatically unsubscribes from the previous observable and subscribes to the new one.