kancur
kancur
WWasp-lang
Created by kancur on 2/16/2024 in #đŸ™‹questions
Using actions inside workers - is it possible?
Oh, I forgot to report here, the workaround worked fine, thanks! đŸ™‚
16 replies
WWasp-lang
Created by kancur on 2/16/2024 in #đŸ™‹questions
Using actions inside workers - is it possible?
Thanks! I thought about that workaround, but assumed there must be a better way đŸ˜„ glad you know about it, will report back after weekend. Thank for you help đŸ™‚
16 replies
WWasp-lang
Created by kancur on 2/16/2024 in #đŸ™‹questions
Using actions inside workers - is it possible?
in my worker, or elsewhere on the backend, I would like to emit an event like io.emit('someMessage', {}); But I don't really have access to io outside of webSocketFn . Do you have some example please? đŸ™‚
16 replies
WWasp-lang
Created by kancur on 2/16/2024 in #đŸ™‹questions
Using actions inside workers - is it possible?
On the frontend, you can use useSocket hook to get the socket instance, but how do I get it on the backend?
16 replies
WWasp-lang
Created by kancur on 2/16/2024 in #đŸ™‹questions
Using actions inside workers - is it possible?
thanks! đŸ™‚
16 replies
WWasp-lang
Created by kancur on 2/16/2024 in #đŸ™‹questions
Using actions inside workers - is it possible?
Thanks, I might have one. I understand that you can get the io object inside webSocketFn like this (copied from docs):
export const webSocketFn: WebSocketFn = (io, context) => {
io.on('connection', (socket) => {
const username = socket.data.user?.email || socket.data.user?.username || 'unknown'
console.log('a user connected: ', username)

socket.on('chatMessage', async (msg) => {
console.log('message: ', msg)
io.emit('chatMessage', { id: uuidv4(), username, text: msg })
})
})
}
export const webSocketFn: WebSocketFn = (io, context) => {
io.on('connection', (socket) => {
const username = socket.data.user?.email || socket.data.user?.username || 'unknown'
console.log('a user connected: ', username)

socket.on('chatMessage', async (msg) => {
console.log('message: ', msg)
io.emit('chatMessage', { id: uuidv4(), username, text: msg })
})
})
}
But how do I use it elsewhere on the server? Where do I get it from? For example when I want to emit an event from the worker, how do I access the io? I can't find it in the docs
16 replies
WWasp-lang
Created by kancur on 2/16/2024 in #đŸ™‹questions
Using actions inside workers - is it possible?
Okay, thanks a lot for the insight! đŸ™‚ I'll take a closer look at the websockets support in wasp đŸ™‚
16 replies
WWasp-lang
Created by kancur on 2/16/2024 in #đŸ™‹questions
Using actions inside workers - is it possible?
I can manually provide an argument for context, but in that case, well, I'm missing the context, like User.
16 replies
WWasp-lang
Created by kancur on 2/16/2024 in #đŸ™‹questions
Using actions inside workers - is it possible?
The point of using an action was to receive a UI update on the client (to invalidate the react-query cache basically). If I edit the db directly from the job, this doesn't update the UI on the client.
16 replies
WWasp-lang
Created by kancur on 2/15/2024 in #đŸ™‹questions
Jobs - Output type error following the example in docs
Okay, I see now! đŸ™‚ Thanks for your help & tips @miho !
26 replies
WWasp-lang
Created by kancur on 2/15/2024 in #đŸ™‹questions
Jobs - Output type error following the example in docs
if it contained value typed Date, it would throw typescript error like mine I think đŸ™‚
26 replies
WWasp-lang
Created by kancur on 2/15/2024 in #đŸ™‹questions
Jobs - Output type error following the example in docs
No description
26 replies
WWasp-lang
Created by kancur on 2/15/2024 in #đŸ™‹questions
Jobs - Output type error following the example in docs
It's basically the OpenSaas template + copy pasting that jobs code from the docs
26 replies
WWasp-lang
Created by kancur on 2/15/2024 in #đŸ™‹questions
Jobs - Output type error following the example in docs
No description
26 replies
WWasp-lang
Created by kancur on 2/15/2024 in #đŸ™‹questions
Jobs - Output type error following the example in docs
Property 'createdAt' is incompatible with index signature.
Type 'Date' is not assignable to type 'JSONValue'.
Type 'Date' is not assignable to type 'JSONObject'.
Index signature for type 'string' is missing in type 'Date'.
Property 'createdAt' is incompatible with index signature.
Type 'Date' is not assignable to type 'JSONValue'.
Type 'Date' is not assignable to type 'JSONObject'.
Index signature for type 'string' is missing in type 'Date'.
26 replies
WWasp-lang
Created by kancur on 2/15/2024 in #đŸ™‹questions
Jobs - Output type error following the example in docs
full error for reference (above)
26 replies
WWasp-lang
Created by kancur on 2/15/2024 in #đŸ™‹questions
Jobs - Output type error following the example in docs
No description
26 replies
WWasp-lang
Created by kancur on 2/15/2024 in #đŸ™‹questions
Jobs - Output type error following the example in docs
No description
26 replies
WWasp-lang
Created by kancur on 2/15/2024 in #đŸ™‹questions
Jobs - Output type error following the example in docs
tried it, doesn't help
26 replies
WWasp-lang
Created by kancur on 2/15/2024 in #đŸ™‹questions
Jobs - Output type error following the example in docs
nope, it doesn't actually work, I no longer see the error in vscode, but it doesn't compile đŸ˜¦
26 replies