Comments (11)
Do you mean a Promise-free version (top to bottom), or you'd like the ability to do node-style callback resolution in the resolve
block?
The internals are doing a Promise.all
, so there would need to be some core equivalency here, whether with an outside dependency (async
?) or similar...
from react-resolver.
Top to bottom would be nice but that's just a pipe dream. Just the ability to do callbacks or whatever in the resolve block is a good start.
Yeah you would need async.parallel
from react-resolver.
I can pretty easily add back in callback support in the resolve
block based on the arity (is that the right word?) of the function.
Behind the scenes, it'll use a Promise to map it.
Is that ok for now?
I didn't know if Promises should be avoided in your estimation, or what?
from react-resolver.
No it's not necessary to avoid them. As long as resolver isn't swallowing errors promises are great.
from react-resolver.
I... guess we're fine then? I do know it's recommended to do Resolver.renderSomehow(...).catch(...)
, since it's promise-driven.
from react-resolver.
I like the idea as well. I'm starting to like generators recently.
from react-resolver.
Pseudo-code:
// where you resolve the promises:
return new Promise((resolve, reject) => {
// create a node-style callback
const callback = (err, value) => err ? reject(err) : resolve(value);
// call the resolve prop
const value = resolveProp(props, context, callback);
// if a Promise is returned then attach to it.
if (value && value.then && typeof value.then === 'function') {
value.then(resolve).catch(reject)
}
})
from react-resolver.
Ahhhh, that takes me back :)
Lines 48 to 54 in b7a46a1
That was a simpler time!
Nice code, BTW. That solves it pretty well.
Now I'm curious. I guess I still use promises wrong??
from react-resolver.
I think if you return the promise itself you'll be a-ok since it'll unwrap itself. I'm probably doing it wrong.
from react-resolver.
Oh no, I think you're right. In one of the other issues, I opted for .then(resolved, rejected)
, whereas I should've just used .then(resolved).catch(errored)
.
from react-resolver.
v2 is a complete-rewrap & will support decorators & a better mechanism with dealing with errors.
TBH, callbacks are soooo great for error states :) Closing to start fresh post-v2...
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.