0

I have a promise which I have to get the value of internally, but it's <value> and <state> properties appear to be inaccessible through normal means. I've never before seen a property with the <bracketed> look, so I'm thinking that might be the clue.

How do I access these properties?

EDIT: I found a way but it is not an answer to the duplicate question

Promise showing inaccessible properties

Code for copy pasting to console:

var test = new Promise(function(resolve) {
  resolve("getMe");
});
Seph Reed
  • 8,797
  • 11
  • 60
  • 125
  • 1
    I don't think these are real properties and you're probably not supposed to access them. – melpomene Nov 02 '16 at 23:23
  • I was thinking the same thing, but they're being accessed somehow for console to show them. And I imagine Promises are written in JS. It would be so cruel to just show these things to people and not let them touch them. Especially when the built in Promise system is so broken for my needs. – Seph Reed Nov 02 '16 at 23:27
  • 2
    This is starting to sound like an XY problem. What exactly is "broken" about promises? – melpomene Nov 02 '16 at 23:28
  • For my purposes, they are a pain as they're asynchronous by default. I don't want to get too off topic, but they basically have a built in setTimeout(0ms) for the sake of forcing async code, but it makes them horrible in scenarios where you might be given a synchronous or asynchronous function and have added complexity for the asyncs. It's also awful for debugging, creating tons of unnecessarily out of order actions. – Seph Reed Nov 02 '16 at 23:32
  • 1
    @SephReed Quite the contrary, promises are **great** for solving problems where you don't know if some condition is synchronous or asynchronous. It seems you're having a conceptual issue, what are you _actually_ trying to do? And for the record, those properties are internal and are only exposed for debugging information, they're not supposed to be accessed. – Etheryte Nov 02 '16 at 23:40
  • Agreed. Promises are great for solving the problem, but the way standard JS Promises are coded, they aren't great for what I'm doing which is having them call .next() immediately if they are synchronous because my debugger jumps around like crazy with everything being forced asynchronous. Also, I have to do a bunch of queuing, which is less efficient than just running and resolving. http://stackoverflow.com/questions/36726890/why-are-javascript-promises-asynchronous-when-calling-only-synchronous-functions – Seph Reed Nov 02 '16 at 23:46
  • thank you for letting me know about internal properties. if you know more about them, please leave an answer so I can accept it. – Seph Reed Nov 02 '16 at 23:49
  • I've marked this question as a duplicate of another one which already covers the topic quite well: [See here](http://stackoverflow.com/questions/30564053/how-can-i-synchronously-determine-a-javascript-promises-state?noredirect=1&lq=1). [This question](http://stackoverflow.com/questions/21485545/is-there-a-way-to-tell-if-an-es6-promise-is-fulfilled-rejected-resolved) may also be of interest. – Etheryte Nov 02 '16 at 23:57
  • Coolio. Well, mystery solved. Thank you. – Seph Reed Nov 03 '16 at 00:00

0 Answers0