Comments (7)
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.
UPDATE:
If I chain the transitions, it works fine
const inc = model => {
model
.count.increment()
.posts.push({ id: Date.now() });
};
from react.
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:
- There is no intermediate state emitted for the increment and the push
- It is batched logically and can be re-used around your application
- this is subtle but important, the
m.inc
function is stable and will not trigger re-renders when the model changes.
from react.
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.
@cowboyd did we fix this?
from react.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react.