Comments (15)
I also realise there are nice benefits to a resolution that only resolves once, and rendering that is delayed until resolution completes. So maybe this "streaming" concept is outside the scope of react-resolver?
from react-resolver.
Hah! My Internet went out why you replied.
Yes, you're correct. The props
should only be resolved once and not mutate. For one, React won't allow this, unless the parent component updates the prop. Otherwise, that's what state
is for.
See the "Counter" example:
http://facebook.github.io/react/tips/props-in-getInitialState-as-anti-pattern.html
But, it means that we should come up with a test-case where the prop may be different with each resolution to ensure the behavior is correct (I think it is, but need to confirm).
from react-resolver.
Yes you're right, it makes a lot of sense to only resolve "props" once but use "state" for ongoing changes.
solve may not be a great solution in its current state then, as it does allow for open-ended "streaming" callbacks, and it also calls its own callbacks multiple times, once for each promise resolution. So it's hard to tell if all the promises have resolved.
I'd considered adding some API to solve to check if the resolution is "done", ie. all callbacks called, all promises resolved, all static data available. It seems this is necessary if react-resolver is going to use it, so it knows when to resolve the "handle" promise.
from react-resolver.
I would like to use it, but, since it is an implementation detail, perhaps we can answer the hard questions for this project & the API first (particularly around errors!), that way we can ensure both projects are in sync.
solve
would be pretty useful for state, it seems. Do you not need stores anymore, since resolutions can keep happening?
from react-resolver.
Yep, many of my stores were just assembling promise results into an object, so solve
replaces most of these.
I agree, using solve
is an implementation detail, more important to nail down the API challenges with the current resolution.
from react-resolver.
I <3 collaborating!
I was going to do another, more complex example with alt. Should I consider Hoverboard as well?
from react-resolver.
Sure, up to you. They're pretty similar, Hoverboard is a bit simpler so might make for an easier example.
from react-resolver.
I've been wrapping my head around this for v1, and it seems this logic is best suited for stores/actions.
from react-resolver.
Agreed. I've come to see "resolution" as something that needs to happen once and be done, that other streaming types of data (eg. chat) should use a different mechanism for updating and re-rendering.
from react-resolver.
Since Facebook's dispatcher has an architectural limitation (1 action per dispatch) on a project, I'm wrapping this project's <Container />
with a "store" that's tracking updates/state, which re-renders the container with new props that re-fetches things.
For streaming, you'd obviously want something different, but this concept is working well for our needs.
from react-resolver.
I've started a branch using csp channels rather than promises with the idea that the server will wait for at least one message and then the client will carry on listening for messages. I'm thinking these channels could be linked to various things - such as updates from flux but also websockets. Rxjs was another option.
https://github.com/gilesbradshaw/react-resolver/tree/csp
from react-resolver.
❤️ that idea. Looking forward to hear how the csp approach works out.
from react-resolver.
I'm thinking it's a more general approach as promises could be fitted into it converted to channels that just have one message.
from react-resolver.
@gilesbradshaw I'm not very familiar with CSP. The biggest issue was knowing when the entire tree is "done". Is that still possible?
from react-resolver.
Nor am I! :P But yes it is/will be at work right now but will reply in more detail later
from react-resolver.
Related Issues (20)
- React.renderToStaticMarkup -> ReactDOMServer.renderToStaticMarkup HOT 2
- Can I use this without server rendering? HOT 3
- Add ability to cache resolved props HOT 9
- Using HOC breaks HMR
- Minimum universal react API HOT 1
- test
- Support variable? HOT 3
- Unhandled rejections server side HOT 1
- @context steals data from this.context HOT 6
- Allow factory to decide which props to re-use? HOT 5
- Documentation links are broken HOT 4
- Using same component on different routes HOT 3
- Using @client and @resolve on the same class causes @resolve to be called twice HOT 1
- Some way of manipulating data before passing it to component HOT 2
- Breakage with React 16: PropTypes no longer exported by React HOT 1
- "[email protected]" has incorrect peer dependency "react@^0.14.6 || ^15.0.0-0" HOT 5
- Need hydrate static method in the Resolver class for server side rendering HOT 2
- Fix compatibility with Babel 6
- Resolve multiple props with one callback HOT 5
- Initial Data from Django using React Resolver HOT 1
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-resolver.