question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`$subscribe` miss mutations with type of `direct` immediately after`patch` mutations

See original GitHub issue

in $subscribe ,I use console to print the mutations and states when the states change :

 store.$subscribe((mutations, state) => {
    console.log('states change :', mutations, state);
  });

it works correct when I change the state directly or use $pacth singlely

// the both ways of the follow work correct
// 1. change directly : ouput is { type:‘direct’ ,... } 
 store.count++


// 2.use $patch : output is {type: 'patch object',...}
store.$patch({
    key: `${Math.random()}`,
 });

but when I use them together as follow,the mutation with type of ‘direct’ will miss ,there is only {type: ‘patch object’,…} on console , and the count value printed was still the old value, actually had increased . seem to not be detected ?

store.$patch({
    key: `${Math.random()}`,
 });
store.count++

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vsamborcommented, Sep 16, 2022

Any way to have access to the mutation path? I have the same problem, I don’t know from which object the mutation is coming.

1reaction
posvacommented, Jan 25, 2022

This might be a caveat that cannot be worked around except by using a flush: 'sync' $subscribe() because currently, in the code, when calling $patch there is

nextTick().then(() => {
      isListening = true
    })
    isSyncListening = true
    // because we paused the watcher, we need to manually call the subscriptions
    triggerSubscriptions(
      subscriptions,
      subscriptionMutation,
      pinia.state.value[$id] as UnwrapRef<S>
    )

Moving triggerSubscriptions() to the nextTick would make this work like you want but break devtools

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mastering Mutations in React Query | TkDodo's blog
Mutations are, per design, not directly coupled to queries. A mutation that likes a blog post has no ties towards the query that...
Read more >
SARS-CoV-2 Viral Mutations: Impact on COVID-19 Tests | FDA
A mutation (also referred to as viral mutation or genetic mutation) of the severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) virus ...
Read more >
Chapter 12: DNA Damage and Repair – Chemistry
Rarely, a missense mutation may be beneficial. Under the right environmental conditions, this type of mutation may give the organism that harbors it...
Read more >
DNA Mutation and Repair
There are three types of DNA Mutations: base substitutions, deletions and insertions. 1. Base Substitutions. Single base substitutions are called point ...
Read more >
Oncogenic mutations mimic and enhance dynamic events in ...
The p110α catalytic subunit (PIK3CA) is one of the most frequently mutated genes in cancer. We have examined the activation of the wild-type...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found