GithubHelp home page GithubHelp logo

Comments (5)

dcodeIO avatar dcodeIO commented on May 22, 2024

See: https://github.com/dcodeIO/ProtoBuf.js/wiki/Reflection

Let me know if this is helpful and feel free to ask questions.

from protobuf.js.

seishun avatar seishun commented on May 22, 2024

Thanks for the quick response.

This works, but a simpler API would definitely help. For example, it's not clear from the documentation that you are supposed to use the resolvedType property to get at a nested message's reflection, and it seems the only way to get to the actual Message class from its reflection is to use the undocumented built property. Let me know if I'm missing something.

from protobuf.js.

dcodeIO avatar dcodeIO commented on May 22, 2024

3a78cec

Thank you for your suggestions. I've changed the API a bit to use more intuitive names. What was built before now is clazz in the context of messages and object in the context of enums. It's also no longer inherited from Reflect.T. Regarding resolvedType, i've added that together with clazz and object to the reflection docs. However, this could possibly break existing programs using ProtoBuf.js at the reflection level, so I've decided to make this v1.1.0.

Please review it again and let me know what you think!

https://github.com/dcodeIO/ProtoBuf.js/wiki/Reflection

from protobuf.js.

seishun avatar seishun commented on May 22, 2024

Thanks, this is exactly what I was looking for.

Another point worth mentioning is that Builder#lookup() works differently from Builder#build() without an argument. While the former returns a Namespace object, the latter returns a name->type map, which I think is more useful, since key lookup is faster than iteration over an array (which, if my understanding is correct, is what happens internally when you provide an argument to lookup).

from protobuf.js.

dcodeIO avatar dcodeIO commented on May 22, 2024

Yes, it's not exactly the same but similar. The recommended way to work with still is Builder#build, while Builder#lookup should be used only if reflection is actually required.

In the process of parsing, building and en/decoding, which is all sequental (name lookups need to be done only once), the array structure of the internal types is more efficient.

from protobuf.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.