ajvincent / es-membrane

An ECMAScript implementation of a Membrane, allowing users to dynamically hide, override, or extend objects in JavaScript with controlled effects on the original objects.
ISC License
109 stars 13 forks source link

Standard distortion type: Wrap one Promise in another for safety #228

Closed ajvincent closed 4 years ago

ajvincent commented 4 years ago

The es-membrane library can't currently inspect the return values of Promise instances. (They're Promises. We don't have their values.)

That said, we can write something like this before it gets through the membrane:

p = p.then(wrapResultAndReturn, wrapResultAndThrow);

ajvincent commented 4 years ago

Relates to #193, #179.

ajvincent commented 4 years ago

The object graph violation comes from Bob.foo = await AliceProxy.foo. At this point, the membrane is no longer in play.

ajvincent commented 4 years ago

This is invalid. It just works.

cliveb commented 4 years ago

@ajvincent Thanks for updating PR. I'm also following observable membrane progress, esp on this PR https://github.com/salesforce/observable-membrane/pull/48