-
-
Notifications
You must be signed in to change notification settings - Fork 59
Add boolean to detect object type #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Would you mind adding that to the docs? |
|
I don't see anything in |
|
adding this to the readme would be good as well.
Il giorno mer 31 lug 2019 alle ore 19:08 James Sumners <
notifications@github.com> ha scritto:
… I don't see anything in docs/API.md for the symbol so I didn't add it for
this. The only mention of this type of stuff in in the README.md.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#40>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAMXY6UGXXQ6OVX2SGJHELQCHBJBANCNFSM4IIGYR5Q>
.
|
|
I did add it to the readme. |
|
I have updated |
mcollina
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
delvedor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
At this point why keep the symbol at all?
|
backward compat for now, we should drop in the next major ideally.
However, it's not that big of a deal to keep
Il giorno gio 1 ago 2019 alle ore 11:25 Tomas Della Vedova <
notifications@github.com> ha scritto:
… ***@***.**** approved this pull request.
LGTM
At this point why keep the symbol at all?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#40>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAMXY4QISFQRGR637EQKNTQCKTZ7ANCNFSM4IIGYR5Q>
.
|
|
Merge release and I’ll submit a PR to Fastify. |
|
I'd prefer to wait for @aboutlo opinion. |
|
Currently in Crete I will have a look over the weekend and get back to you
On Thu, 1 Aug 2019 at 16:28, Matteo Collina ***@***.***> wrote:
I'd prefer to wait for @aboutlo <https://github.com/aboutlo> opinion.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#40>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJN2LBRK2MN6GOTKPGOY2LQCLQIJANCNFSM4IIGYR5Q>
.
--
Sent from mobile phone
|
|
hey, @jsumners thank you for opening the PR! A couple of things:
Could you add a test to reproduce your cloning issue? Maybe in the Integration tests I would expect to have similar issues given I do a lot of deconstructing internally at FluentSchema, but maybe I have been lucky. I'm worried that Fluent Schema has an internal util method https://github.com/fastify/fluent-schema/blob/5382d9bfce1d630356878289e1abb06a57057882/src/utils.js#L3 that has been changed to use the symbol. So if we can reproduce the issue I would expect we need to move to the boolean implementation in order to fix it |
|
Good call on the integration test. It seems I was wrong about I see that I can probably rework how I'm cloning my objects in my project (possibly), but I also think the usage of a |
|
I think the use case to detect if an object is a FluentSchema makes sense but not sure about the best implementation between Symbol vs Boolean. We should only have one approach and if Symbol works I would keep it rather than changing the API. @delvedor, you have originally proposed the Symbol approach do you have any suggestion? |
|
Symbols are useful when the property doesn’t need to be exposed during serialization or to keep the property “private”. Neither situation applies here. The regular property is less mysterious and easier to use. |
|
+1 on using a property
Il giorno sab 3 ago 2019 alle 16:58 James Sumners <notifications@github.com>
ha scritto:
… Symbols are useful when the property doesn’t need to be exposed during
serialization or to keep the property “private”. Neither situation applies
here. The regular property is less mysterious and easier to use.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#40>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAMXY244S3QB4YMAY2Q27DQCWMKPANCNFSM4IIGYR5Q>
.
|
|
@delvedor are you +1 for using a plain property? |
|
OK, given there is a general consensus if no news hopefully this evening I will move forward with the boolean approach |
The issue I was having in #39 was due to object composition and cloning. I have a wrapper around Fastify that reads a list of routes from
config/routes.jsand then the corresponding handlers fromlib/handlers/. For example:config/routes.js:lib/handlers/foo.js:So these two files are read in and the objects are merged to build up the full route definition before being passed to
fastify.route. If any of the schemas arefluent-schemainstances then theSymbol.for('fluent-schema-object')will be lost during this process because symbols do not get copied in any current object merging method (by design). But if we don't retain the ability to determine if the schemas are instances offluent-schemathen we can't work with these schemas during the schema compilation process. Thus, this PR adds anisFluentSchemaboolean to use instead of the symbol.