Giter Site home page Giter Site logo

Comments (3)

dai-shi avatar dai-shi commented on May 27, 2024

Nice catch.

Hm, I naively thought about delaying like this,

diff --git a/src/vanilla/store.ts b/src/vanilla/store.ts
index fa7e7fb..e84a632 100644
--- a/src/vanilla/store.ts
+++ b/src/vanilla/store.ts
@@ -562,9 +562,11 @@ export const createStore = () => {
     const result = writeAtomState(atom, ...args)
     const flushed = flushPending()
     if (import.meta.env?.MODE !== 'production') {
+      Promise.resolve().then(() => {
         storeListenersRev2.forEach((l) =>
           l({ type: 'write', flushed: flushed as Set<AnyAtom> })
         )
+      })
     }
     return result
   }

but maybe we should do it in useAtomsDebugValue?

from jotai.

yf-yang avatar yf-yang commented on May 27, 2024

LGTM, btw is queueMicroTask better?

from jotai.

dai-shi avatar dai-shi commented on May 27, 2024

Well, our build still targets IE 11,

babelPlugin(getBabelOptions({ ie: 11 })),

even though, it may not work perfectly.

queueMicroTaks doesn't seem available: https://caniuse.com/mdn-api_queuemicrotask

but maybe we should do it in useAtomsDebugValue?

I don't think we should add a delay in Jotai, because there are some use cases for sync behavior.
Can you open a PR in jotai-devtools?

from jotai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.