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
well yes you can through sequential expressions (
width(), count() * 2;
) but why?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: 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
thanksIt 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
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
Yeah I think you probably want that to be a signal
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