Comments (8)
Good idea, you can send a PR :D
from react-async.
I do have a PR for this but it would require a polyfill like es6-promise
or something for cross-browser support. Otherwise only modern browsers have native Promise
from react-async.
Does it really require depending on promise library?
What about something like this:
var ReactAsyncWithPromisesMixin = {
getInitiatStateAsync: function(cb) {
this.getInitialStatePromise().then(
function(result) { cb(null, result); },
function(err) { cb(err); }
);
}
}
from react-async.
that definitely work, but where would getInitialStatePromise
come from though? If that's implemented by user then wouldn't getInitialStateAsync
be redundant?
from react-async.
What about...
var promise = this.getInitialStateAsync(cb);
if (promise && typeof promise.then === 'function') {
promise.then(cb.bind(cb, null), cb);
}
It would be inside the #wrap callback of this line
Line 40 in fd875a5
from react-async.
yeah I think that's more like it
from react-async.
@longlho yes, in my example there's a separate mixin for promises which requires implementing a different method getInitialPromiseState
where getInitialStateAsync
already implemented.
Checking getInitialStateAsync
for a resulted value is a good idea. That way we reduce API surface by not having an additional mixin.
from react-async.
👍
from react-async.
Related Issues (20)
- [idea] refreshable component? HOT 11
- peerinvalid cannot satisfy peerDependencies HOT 2
- A couple outdated modules HOT 1
- Different component fingerprint on client/server HOT 11
- Bug in nested ReactAsync.Mixin? ("render" called before "getInitialStateAsync") HOT 2
- Server: Can we render to a buffer? HOT 1
- Getting rid of "localhost:3000" URLs HOT 3
- support for react 0.11.2 HOT 1
- Using session information for server-rendered pages. (Logging in.) HOT 1
- Superagent call when javascript is Off on the browser HOT 2
- render a component outside React from client side in an isomorphic app HOT 2
- Thoughts on Relay? HOT 2
- this.<function from another mixin> is undefined in browser (isomorphic app)
- [BROKEN] getComponentFingerprint HOT 6
- client bootstrapping json does not work correctly if page has multiple async components HOT 2
- reset Preloaded component and force preloader and getInitialStateAsync call
- object is not a function
- render with only component markup
- When you will release es6-compat version described in readme doc? HOT 1
- React 0.14.x Support HOT 4
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-async.