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.
111 stars 13 forks source link

show and tell: read-only handler #220

Closed kumavis closed 5 years ago

kumavis commented 5 years ago

I created a read-only handler.

I would like to know:

I'm having some trouble learning how to use es-membrane and I think a set of examples would help. Sometimes the spec tests are helpful, but they are often abstract.

ajvincent commented 5 years ago

First off, have you looked at the Distortions User Interface? I wrote that tool to make configuring a membrane much easier. It might not do what you want, yet.

Technically, under the current implementation, you're supposed to use a ChainHandler. See source/ModifyRulesAPI.js, in the createChainHandler method.

But that approach is deprecated because of a major refactoring I'm (very slowly) implementing to break up ObjectGraphHandler.js into much smaller, unit-testable pieces. The ChainHandler concept itself is also deprecated. The refactor introduces a linked-list proxy handler design, wherein specific distortions such as read-only access can be introduced in the middle much more flexibly.

Please be aware that my response time to bug requests is going to be slow for a while, due to commitments I have in both university and my current job. I do appreciate the feedback. I'm just not able to put in the time you might reasonably expect to add new features right now. (Hence the long backlog.)

kumavis commented 5 years ago

First off, have you looked at the Distortions User Interface? I wrote that tool to make configuring a membrane much easier. It might not do what you want, yet.

yeah, i poked around a bit and it helped introduce me to some useful APIs. its a little jarring to jump into without much context. While I think it could be a very powerful tool, I think the repo would get better mileage from more basic documentation and usage examples first.

Please be aware that my response time to bug requests is going to be slow for a while, due to commitments

oh no worries, mostly just wanted to post some examples for future spelunkers.

I need a membrane implementation and so far yours is my favorite! I may be able to do some maintenance and sponsor an audit. In the mean time I'll keep digging around for a bit.

ajvincent commented 5 years ago

Actually, if you want to lend a hand, there's #205 . Granted, you'd have to build it off of MembraneProxyHandlers.Forwarding, but we can fix that later...

ajvincent commented 5 years ago

OK, there's now a LinkedListNode base class available: https://github.com/ajvincent/es-membrane/tree/refactor-0.10/source/ProxyHandlers