corenova / yang-js

YANG parser and composer
Apache License 2.0
56 stars 18 forks source link

Should Property.detach/attach() function be public or private? #96

Closed quantang closed 5 years ago

quantang commented 5 years ago

Hello @saintkepha,

I noticed that we don't have Property.remove() function anymore. It looks like the Property.detach() would be the replacement of the original remove() function based on your example of "restjson.js" in yang-express. So I will try to add the detach() function in the Typescript declaration file.

On the other hand, I see the corresponding Property.attach() function. But I guess it should be used internally only, right? In other words, I should not add it to the Typescript declaration, as the users should use create() function of the list.

Please feel free to share your thoughts. Cheers.

sekur commented 5 years ago

The new design intention is that attach/detach should be private/internal. However, I don't have a good pattern for performing delete/remove operation, especially given the functional role separation between Container and Property when it comes to dealing with sub properties and the runtime state operations delegated to the Proxy object.

As to typescript, we should document them both to be internal... even though in restjson module, we use it directly for now.

sekur commented 5 years ago

On the latest yang-js (0.22.17) I've introduced Property.delete which should now be the public interface for the prior remove/detach method.

I've updated yang-express (0.7.0) to use the new public delete() method as well.

We should update typescript interface accordingly.