Closed VanTanev closed 9 years ago
Sorry about this. A workaround is that the variable should be available at Reflux.utils.environment.hasPromise
.
This workaround doesn't seem to work for me in node.js on some OS's. Feels like at least anything with "setPromise" explicitly used (as in the docs) should work, even if it's failing to detect promises in other ways.
I did find a workaround that works, but it's terribly evil.
global.Promise = require('bluebird')
at the very beginning of my app worked, even where
Reflux.utils.environment.hasPromise = true
failed when run on every line.
Yes @abraxas, you need to polyfill Promises in NodeJS (i.e. in server-side). This is because Node does not have Promises implemented yet IIRC.
Hey, currently
_.environment.hasPromise
is used to determine if Reflux should trigger an action as a promise, or as an async (ref). This however only depends on an initial check of the environment done here: https://github.com/reflux/reflux-core/blob/b291e3dbf897dd61cbc90fdfb377d46f6a6e5a2c/src/utils.js#L27This means that even if we provided another promise implementation to Reflux through
Reflux.setPromise(require('bluebird'))
, Reflux would not trigger promises, because we cannot influence the_.environment.hasPromise
variable.We need to either be able to influence this variable, or it needs to be automatically set to true when an external promise lib is set in https://github.com/reflux/reflux-core/blob/b291e3dbf897dd61cbc90fdfb377d46f6a6e5a2c/src/index.js#L74-L88