S
SolidJS2y ago
Grahf

Is it possible to activate a derived signal with an unrelated signal?

So that const doubleCount = () => count() * 2; would activate if say the signal width() changed?
7 Replies
lxsmnsyc
lxsmnsyc2y ago
well yes you can through sequential expressions (width(), count() * 2;) but why?
Grahf
GrahfOP2y ago
I need this derived signal to update when the window height changes. const maxPage = () => { if (props.paragraphsLoaded === 'ready') return Math.ceil(scrollWidth() / windowSize.width - 1) else return 0 } Even though the height isn't part of the equation if you lower the height of the window then the text wraps past the max page like this screenshot:
Grahf
GrahfOP2y ago
const maxPage = () => { if (props.paragraphsLoaded === 'ready') return Math.ceil( scrollWidth() / windowSize.width - 1 + windowSize.height - windowSize.height ) else return 0 } Works fine but it's silly to add and subtract the same number thanks
fabiospampinato
It sound like you want a signal for the window width and to read both in your function, I'm not sure a strict solution to this question ever actually makes sense
Grahf
GrahfOP2y ago
So maybe make window width a signal? I also think my scroll width isn't changing because it should change when the height of the window changes And then I wouldn't have to worry about the height
fabiospampinato
Yeah I think you probably want that to be a signal
Grahf
GrahfOP2y ago
ok setting scrollwidth and windowwidth to a signal works and I don't have to worry about adding a sequential expression for the height since as the height decreases scrollwidth increases
Want results from more Discord servers?
Add your server