This repository has been archived by the owner on Jan 1, 2025. It is now read-only.
Replies: 2 comments 8 replies
-
Seems like you could accomplish this with a // import currentBrandId Atom
import { currentBrandId } from ...
const currentProductList= selector({
key: 'current-product-list',
get: ({get}) => {
const brandId = get(currentBrandId)
// logic from "productList" to return product list for the brandId
}
}); |
Beta Was this translation helpful? Give feedback.
8 replies
-
Thanks @rbaxter08 Also please see this example in the docs for this pattern. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm curious if there's a way for
atomFamily
s to rely on anatom
without needing to fetch/pass it in each consuming component.Here's an example of a code pattern I find myself repeating all over:
currentBrandId
is anatom
because it's not uncommonly user-changed.productList
is anatomFamily
to deal with things like data refreshes/updates.We're already saving
currentBrandId
insessionStorage
as part of its set method.It'd be nice to register a listener on
sessionStorage
to keep the logic together and smaller.Beta Was this translation helpful? Give feedback.
All reactions