Comments (3)
Hey @PalmZE, thanks for such a detailed issue!
So, correct me if I'm wrong, the issue is that during rendering of list items that reference list values in Properties by index, we can get out of sync with the data because this list item component is not unmount in time, right? This happens due to asynchronous nature of the renderer, right? Then I would expect such components reading the data by index to check whether the item is not undefined
. That would be the correct behavior to work with changing lists and "stale" indexes. By "stale" I mean that they might get out of sync due to async rendering in React. That's a common problem actually and it's not related to setting the state in the render cycle. The wrong index, captured during rendering of the list, might reference non-existing item anyway, as the rendering most of the times is out of sync with the data (especially taking React's Concurrent Mode into account). So, in short, I would say it's the responsibility of the UI composition to write to
/read from
Atom
/Property
correctly.
Originally, @frp-ts/core
was design to be fully synchronous at its heart, so although most
and other libs implement asynchronous value delivery (microtasks for example), I'm not sure whether it's a good option to adopt similar concept here. At the end of the day, it's not the responsibility of Atom
to think about how/when the value should be delivered to its consumers, but of the caller of Atom#set
. In most cases, synchronous emission is enough, in some cases (like with React) it may break things but we should think about such cases outside of the core. For example, it's fine to tackle this in @frp-ts/react
.
Ok, now speaking about @frp-ts/react
, honestly I don't know wtf is use-subscription
/``use-mutable-source` or any other fancy APIs they are going to bake into the core :D. But, seems until it's not in the core, we are free to ignore it. At the same time, I think it's fine to think about improving existing bindings to React if there are any issues with them.
Thanks for opening the issue and let's continue the discussion here.
from frp-ts.
So, in short, I would say it's the responsibility of the UI composition to write to/read from Atom/Property correctly.
I thought a bit more about the issue, and I agree.
At the same time, I think it's fine to think about improving existing bindings to React if there are any issues with them.
Existing bindings are working fine. This is an approach similar to other libraries (mobx, effector, etc).
I created this issue to discuss the possibility of using useSyncExternalStore
since it simplifies the usage of atom-like
sources. But, I agree that until this api is in the core (and React 18 is released) current version is safer.
I'll test useSyncExternalStore
in my own project. Can let you know, if it works ok in the long run.
Conclusion: I have nothing to add, feel free to close this issue.
from frp-ts.
Thanks for the feedback @PalmZE. Closing.
from frp-ts.
Related Issues (18)
- combine function for property HOT 5
- perf files contain ts errors HOT 2
- Unstable default clock HOT 1
- Optimise construction of observer in mergeMany combinator
- `fromObservable` should subscribe only if there any subscription
- [Question] Is it really beneficial to have implicit filtering logic on value set? HOT 3
- Docs: Clearly describe why `Property`/`Atom` skips duplicates by default in documentation
- feat: compatible with svelte by default HOT 1
- Add LICENSE HOT 1
- Link NPM packages to repository
- bug: coverage is not checked
- `Property` example in README fails to compile HOT 1
- @frp-ts/state addition HOT 7
- feat: distinctUntilChanged operator HOT 1
- [Question] Duped values - do not propagate events or simply return cached value HOT 2
- [QUESTION] There are no reactions in the react component HOT 2
- usePropertyFromProps inconsistency
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 frp-ts.