Skip to content

$subscribe miss mutations with type of direct immediately afterpatch mutations #992

Open
@duoyue

Description

@duoyue

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++

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionhas workaroundThe issue contains a temporary solution to get around the problem

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions