Skip to content

Realtime/sub JSON field issue ? v0.22.11 #4881

Closed Answered by bloor
bloor asked this question in Q&A
Discussion options

You must be logged in to vote

FIXED

I was unknowingly applying transformation on the record, right inside the subscribe event loop.
I commented the bad code.
The difficult debugging part was , that console.log() , even being before anything else, was returning the already transformed value. So it was sending me in tail chase mode.

await $pb.collection('users_stats_collect').subscribe('*', (e) => {
    console.log(e.record)
    if (e.action == 'create'){
        players.value.push(e.record)
    }

    if (e.action == 'update'){
        players.value.forEach((p,i) => {
            if (p.id == e.record.id){
                // players.value[i] = e.record // BAAAAAAAAAAAD
                players.value[i] = {...e.record} //…

Replies: 5 comments 5 replies

Comment options

You must be logged in to vote
2 replies
@bloor
Comment options

@ganigeorgiev
Comment options

Comment options

You must be logged in to vote
1 reply
@ganigeorgiev
Comment options

Comment options

You must be logged in to vote
2 replies
@ganigeorgiev
Comment options

@bloor
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by bloor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #4880 on May 08, 2024 06:27.