bigmistqke
bigmistqke
SSolidJS
Created by hcker2000 on 12/6/2024 in #support
Error when trying to use provider method
for example
// main.js
import "./module1"
import "./module2"

// module1.js
console.log('hallo')

// module2.js
import "./module2"
// main.js
import "./module1"
import "./module2"

// module1.js
console.log('hallo')

// module2.js
import "./module2"
is only going to log 'hallo' once: that's because the body of a module is only called once: the first time it is imported from somewhere.
69 replies
SSolidJS
Created by hcker2000 on 12/6/2024 in #support
Error when trying to use provider method
you can scope variables that are used throughout your project just with files, you don't need additional abstractions.
69 replies
SSolidJS
Created by hcker2000 on 12/6/2024 in #support
Error when trying to use provider method
no! that's the beauty of modules
69 replies
SSolidJS
Created by hcker2000 on 12/6/2024 in #support
Error when trying to use provider method
this is what i was thinking: store.js
const [store, setStore] = createStore({ ... })
export function getUser(){
return store.user
}
export function setUser(user){
setStore({user})
}
export functio addTodo(todo){
setStore('todos', todos => [...todos, todo])
}
// etcetera
const [store, setStore] = createStore({ ... })
export function getUser(){
return store.user
}
export function setUser(user){
setStore({user})
}
export functio addTodo(todo){
setStore('todos', todos => [...todos, todo])
}
// etcetera
main.js
import { setUser } from "./store"
setUser({ ... })
import { setUser } from "./store"
setUser({ ... })
69 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
if you have make some progress at some point, definitely share in https://discord.com/channels/722131463138705510/734440921776783391 would love to follow up
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
the more solid web builders the merrier
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
also don't know if you already saw it, but since you mentioned you are building a website builder: https://discord.com/channels/722131463138705510/1201177657480577195
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
especially w this type of nested tree stuff it can get spaghetti very fast!
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
often when doing recursion you can get away with doing loops too
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
you are very welcome!
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
but i think the main idea is good: just walk that tree
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
I think there might be a cleaner way of expressing this, something like:
setStore(produce(store => {
let currentElement
while(element_indexes.length > 0){
currentElement = (currentElement ?? store.page).elements[element_indexes.shift()];
}
// mutate currentElement
}))
setStore(produce(store => {
let currentElement
while(element_indexes.length > 0){
currentElement = (currentElement ?? store.page).elements[element_indexes.shift()];
}
// mutate currentElement
}))
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
o i see
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
pageStore.page.elements[element_indexes[0]] this line gives me the impression that you do know the path, but mb i m misunderstanding the code
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
why not do setStore('page', 'elements', element_indexes[0], ...) ?
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
what i am not completely getting from your code is
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
thank u!
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
the first backticks
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
(could u add syntax highlighting to the snippet? add tsx after the triple backticks)
31 replies
SSolidJS
Created by andahendriksen on 12/11/2024 in #support
Setting infinitely deep store?
you are very welcome!
31 replies