-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
Add Effect.Tag to simplify access to service #2225
Conversation
🦋 Changeset detectedLatest commit: f8aba10 The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
packages/effect/src/Effect.ts
Outdated
TagClass["$"] = new Proxy({}, { | ||
get(_target: any, prop: any, _receiver) { | ||
// @ts-expect-error | ||
return core.andThen(TagClass, (s) => s[prop]) |
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.
maybe cache?
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.
caching proxy leads to Max Call Stack
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.
I mean like this https://github.com/Effect-TS/effect/pull/2230/files
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.
I think this would be slower, not sure, the issue caching would try to prevent is proxy access but proxy is accessed anyway, for the rest a cache lookup or a single function call have comparable overhead
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.
my point was more like garbage, creating a new function instead of lookup and return old. at least for the function case. but sounds like micro optimisations, especially considering all the functions we create and destroy on our side of the pond :D
@mikearnaldi is it intentional that the like this would do: |
It is intentional, if the signatures are not the same they are not dupes. Every member is available to be accessed as a constant |
it's of arguable importance though |
yea, if you don't access it for use, it's kinda better to consume the service. rn it's kinda just confusing imo |
@mikearnaldi infer to |
No description provided.