various attempts at implementing transparently composable Promises #41
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Gave a shot at implementing this. One desirable (although possibly not mandatory) characteristic would be returning the "previous" value the variable held, while currently holding a Promise value. I wasn't able to follow all the conditions under which this value gets set/returned; i ended up overriding
this.value
via a setter/getter, although I wasn't successful in capturing/intercepting all possibilities.Alternative is to just return
undefined
whenever the Variable holds an unfulfilled Promise, which will work as long as the consuming code knows how to interpret this.Update: updated with a simple helper that just does the decoupled subscribe/put