Git Product home page Git Product logo

Comments (7)

mwq27 avatar mwq27 commented on June 12, 2024 1

Oooh interesting, I didn't even think to put anything else really on the models. I'll update my code to do it that way instead.

Also great work on this library! I was at Framework Summit a few weeks ago when you talked about this and it got me really interested.

from react.

mwq27 avatar mwq27 commented on June 12, 2024

UPDATE:
If I chain the transitions, it works fine

const inc = model => {
    model
        .count.increment()
        .posts.push({ id: Date.now() });
  };

from react.

cowboyd avatar cowboyd commented on June 12, 2024

Marques,

That is very interesting. I would have expected your initial example to work as well.

That said, if it is possible it is best to include the transitions on the actual microstate models themselves like I have done in this example https://codesandbox.io/s/31x8llnjjm

This has a number of benefits:

  1. There is no intermediate state emitted for the increment and the push
  2. It is batched logically and can be re-used around your application
  3. this is subtle but important, the m.inc function is stable and will not trigger re-renders when the model changes.

from react.

cowboyd avatar cowboyd commented on June 12, 2024

Glad you like it! Please keep the questions coming. I'm leaving this issue open, since even though there is a good work around, it seems like it could still very well be a bug.

from react.

taras avatar taras commented on June 12, 2024

@cowboyd did we fix this?

from react.

cowboyd avatar cowboyd commented on June 12, 2024

I don't know actually. The problem is that the model reference is "stale". Note that the changes in thefrontside/microstates#317 will make it no longer chainable.

from react.

taras avatar taras commented on June 12, 2024

I'm going to close this issue. @mwq27 feel free to reopen it if this issue is not resolved for you.

from react.

Related Issues (5)

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.