d34dbug
d34dbug
SSolidJS
Created by d34dbug on 1/18/2024 in #support
Reactivity lost if awaited function precedes?
Thank you. I am feeling much better than I was, but I am so behind.
33 replies
SSolidJS
Created by d34dbug on 1/18/2024 in #support
Reactivity lost if awaited function precedes?
😦 Looks like I'm not going to be able to at the moment. Turns out I got sick and it put me out of commission for several days. I'm just too way behind on where I'd like to be on my project now. Sorry.
33 replies
SSolidJS
Created by d34dbug on 1/18/2024 in #support
Reactivity lost if awaited function precedes?
I'm not sure as I won't have time til Monday at the earliest and I'll have to figure out how to simulate a basic backend behavior. I'll see what I can do.
33 replies
SSolidJS
Created by d34dbug on 1/18/2024 in #support
Reactivity lost if awaited function precedes?
the only difference seems to be that the call to the signal getter is happening inside the await in my initial code. It's also called repeatedly, but that doesn't seem likely to be an issue. If the problem is that the signal getter is called inside the await, that might warrant a deeper dive into the reason or maybe an informative post indicating that this shouldn't be done (calling the getter inside an await)
33 replies
SSolidJS
Created by d34dbug on 1/18/2024 in #support
Reactivity lost if awaited function precedes?
current that doesn't work:
<button
id="but_sel"
onClick={async (e) => {
e.preventDefault();
if(sessionSelected()){
await set_session({id:sessionSelected()});
console.log(sessionSelected())
props.setActiveSession(sessionSelected());
props.setSection(undefined);
}else{
await message("please choose a session");
}
}}
>
<button
id="but_sel"
onClick={async (e) => {
e.preventDefault();
if(sessionSelected()){
await set_session({id:sessionSelected()});
console.log(sessionSelected())
props.setActiveSession(sessionSelected());
props.setSection(undefined);
}else{
await message("please choose a session");
}
}}
>
this does seem to work:
<button
id="but_sel"
onClick={async (e) => {
e.preventDefault();
let session = sessionSelected();
if(session){
await set_session({id:session});
console.log(session)
props.setActiveSession(session);
props.setSection(undefined);
}else{
await message("please choose a session");
}
}}
>
<button
id="but_sel"
onClick={async (e) => {
e.preventDefault();
let session = sessionSelected();
if(session){
await set_session({id:session});
console.log(session)
props.setActiveSession(session);
props.setSection(undefined);
}else{
await message("please choose a session");
}
}}
>
33 replies
SSolidJS
Created by d34dbug on 1/18/2024 in #support
Reactivity lost if awaited function precedes?
I did however have to remove the {} from:
await set_session({sessionSelected()});
await set_session({sessionSelected()});
Because I was getting the error that a signature could only be used in tsx, or something like that
33 replies
SSolidJS
Created by d34dbug on 1/18/2024 in #support
Reactivity lost if awaited function precedes?
It logs the correct Id, but it fails to be reactive - i.e. the parent component is not rendered.
33 replies
SSolidJS
Created by d34dbug on 1/18/2024 in #support
Reactivity lost if awaited function precedes?
Odd! That seems to be working. I'll do some more testing to make sure, but weird. I'm very curious why that would change anything functionally.
33 replies
SSolidJS
Created by d34dbug on 1/18/2024 in #support
Reactivity lost if awaited function precedes?
ok, not done that before. Cool!
33 replies
SSolidJS
Created by d34dbug on 1/18/2024 in #support
Reactivity lost if awaited function precedes?
gotcha, so you just add the tsx or jsx after the ```?
33 replies
SSolidJS
Created by d34dbug on 1/18/2024 in #support
Reactivity lost if awaited function precedes?
not sure how that works for the highlighting. I 've chosen not to use typescript because I can't deal with all the error messages. I kinda want to limit the number of things I'm trying to learn at one time. Solid and Rust are enough with all the other libraries associated.
33 replies
SSolidJS
Created by d34dbug on 1/18/2024 in #support
Reactivity lost if awaited function precedes?
in case it matters this is in the parent component:
const fetchSession = async () => {
const sess = await get_session_id(); //this needs to return undefined if error
return sess;
};
const fetchScope = async () => {
const scope = await get_session_scope(); //this needs to return undefined if error
return scope;
};

export default function MainContents(props) {
const [activeSession, setActiveSession] = createSignal();
const [sessionId] = createResource(activeSession,fetchSession);
const [currentScope]=createResource(sessionId,fetchScope);
const fetchSession = async () => {
const sess = await get_session_id(); //this needs to return undefined if error
return sess;
};
const fetchScope = async () => {
const scope = await get_session_scope(); //this needs to return undefined if error
return scope;
};

export default function MainContents(props) {
const [activeSession, setActiveSession] = createSignal();
const [sessionId] = createResource(activeSession,fetchSession);
const [currentScope]=createResource(sessionId,fetchScope);
The idea is to use the activeSession as a trigger to validate that the session in the backend which then triggers a validation of whether the scope is set in the backend. These are used to conditionally render the parent component. It sounds convoluted and it kinda is, but it's because I am trying to rely on state on the backend, not the frontend.
33 replies
SSolidJS
Created by d34dbug on 1/18/2024 in #support
Reactivity lost if awaited function precedes?
pretty sure you can think of the set_session as a fetch. The difference is that it's fetching from a local instance of the Tauri backend: string goes out, string comes back.
33 replies
SSolidJS
Created by d34dbug on 1/18/2024 in #support
Reactivity lost if awaited function precedes?
set_session is a tauri function calling the backend:
export async function set_session({ id }) {
let msg = {
id: id
};
let val = await invoke("set_session", { "msg": JSON.stringify(msg) });
return val
}
export async function set_session({ id }) {
let msg = {
id: id
};
let val = await invoke("set_session", { "msg": JSON.stringify(msg) });
return val
}
props.setActiveSession is the setter for a signal in the parent component
33 replies
SSolidJS
Created by d34dbug on 12/27/2023 in #support
Right side of assignment cannot be destructured
That was the problem. Strange. Thanks. I should have seen that. I think what threw me was the error message which didn't seem to have anything to do with the actual error not providing parameters that are expected/required
8 replies
SSolidJS
Created by d34dbug on 12/27/2023 in #support
Right side of assignment cannot be destructured
Thank you for that. Definitely an oversight from copying it over. However, how would that lead to the error I'm receiving? I could see an error telling me that parameters are missing or something, but the error doesn't seem to line up with that. Just a bad error message? Unfortunately I won't have time to work on it until maybe tomorrow to test if that's the cause of the error.
8 replies