Skip to content

Add init accessor to DependencyEndpoint macro #362

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AgapovOne
Copy link

@AgapovOne AgapovOne commented Apr 23, 2025

I'm attempting to fix behavior that broke after #355.

cc @mbrandonw

I've added initAccessor boolean property, added snapshot tests for possible scenarios.


Still in draft because it would have a possible bug that were removed from documentation in release 1.9.2:

Old bug reproduced Screenshot 2025-04-23 at 11 28 40

I tried to add tests on issuereporting call that would be expected in this scenario.

I'm open to ideas on how we can fix this.

If we can't, probably asking everyone to provide own init is better than have this bug still here.

The library works fine with all old cases, and I just found one specific case that would break it, but it can be avoided with custom init.

@mbrandonw
Copy link
Member

Hi @AgapovOne, I am starting to feel that even allowing the initAccessor option is maybe too much of a footgun. I just don't think people should be using @DependencyEndpoint directly. It really doesn't do that much for you. Instead of this:

@DependencyEndpoint
public var set: (ValueType?) -> Void

…you do this:

public var set: (ValueType?) -> Void = unimplemented("Unimplemented: \(Self.self).set")

So, while our change was technically a breaking change, there is a clear migration path forward, and I think we want to overall discourage people from using @DependencyEndpoint. We should probably deprecate it and replace it with @_DependencyEndpoint.

What do you think?

@AgapovOne
Copy link
Author

I think we shouldn't bring my change into repository because it brings again this issue with missing reportIssue call.

But I want to explain where I'm using @DependencyEndpoint now.

@DependencyEndpoint
public var set(_ value: ValuType?) -> Void

Brings me named arguments. That's the only thing I'm using it for.

set(value: nil)

It's probably better to write it myself now. Or look for other macro.


deprecate it and replace it with @_DependencyEndpoint.

The point of this would be to discourage it's use without @DependencyClient?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants