Skip to content
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

Added dependency injection #1662

Merged
merged 7 commits into from
Apr 20, 2024
Merged

Added dependency injection #1662

merged 7 commits into from
Apr 20, 2024

Conversation

FastestMolasses
Copy link
Member

Description

Added the dependency injection system using property wrappers. Right now, this is the simplest way of adding dependency injection, over the macro based solutions. The decision to use a macro based DI can be discussed in the future, and changing DI systems will be an easy refactor for this code.

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

Copy link
Member

@tom-ludwig tom-ludwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really clean code, love it!
Just a few small changes, not sure if all are correct 😅

0xWDG
0xWDG previously approved these changes Apr 3, 2024
Copy link
Collaborator

@0xWDG 0xWDG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, i didn't know ObjectIdentifier but i agree with @activcoding is we can use a identifier, we should.

Copy link
Contributor

@matthijseikelenboom matthijseikelenboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks decent enough, I might add something after the current comments have been processed/fixed.

However, what I would absolutely want with this PR is extra documentation in the Documentation.docc. As those cannot contain diagrams, code snippets would be nice. Next to that, if this is merged, we need to add a wiki page for, where we can have those diagrams.

Lastly, I'm not sure if a DependencyInjection folder in features is the right place to put this? Like, it's not really a feature feature, more of a support library. What do others think?

Refactors and made ServiceContainer thread safe
@FastestMolasses
Copy link
Member Author

FastestMolasses commented Apr 9, 2024

However, what I would absolutely want with this PR is extra documentation in the Documentation.docc. As those cannot contain diagrams, code snippets would be nice. Next to that, if this is merged, we need to add a wiki page for, where we can have those diagrams

I'm thinking we can make a section titled Services, where we can talk about the Service and provider pattern in general, when to use it and when to make one. And then we can also talk about how our dependency injection works with the services. What do you think? If so, let me add it in the FileService PR.

Lastly, I'm not sure if a DependencyInjection folder in features is the right place to put this? Like, it's not really a feature feature, more of a support library. What do others think?

I agree, I moved it under the Utils folder. I made a Service folder for the FileService PR where all the services are intended to go. Since this is directly related to the services maybe we should move it there? Thoughts?

@FastestMolasses
Copy link
Member Author

FastestMolasses commented Apr 9, 2024

Thanks for the great suggestions, made an update and requesting a re-review.

Also does anyone know how to fix this build error for my PR?

error: Build input files cannot be found: '/Users/administrator/actions-runner/_work/CodeEdit/CodeEdit/CodeEdit/Features/DependencyInjection/ServiceContainer.swift', '/Users/administrator/actions-runner/_work/CodeEdit/CodeEdit/CodeEdit/Features/DependencyInjection/ServiceType.swift', '/Users/administrator/actions-runner/_work/CodeEdit/CodeEdit/CodeEdit/Features/DependencyInjection/ServiceWrapper.swift'. Did you forget to declare these files as outputs of any script phases or custom build rules which produce them? (in target 'CodeEdit' from project 'CodeEdit')

Update: Looks like it's working now

tom-ludwig
tom-ludwig previously approved these changes Apr 17, 2024
Copy link
Member

@tom-ludwig tom-ludwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really excited to get this started(Thanks for the good docs, saved me a lot of thinking...)!
By the way, have you had a chance to test the code with the new ObjectIdentifier(.:)?

CodeEdit/Utils/DependencyInjection/ServiceType.swift Outdated Show resolved Hide resolved
@FastestMolasses
Copy link
Member Author

By the way, have you had a chance to test the code with the new ObjectIdentifier(.:)?

This PR doesn't have any services to test it but I am using this most up to date implementation in the experimental branch and its working pretty well!

@FastestMolasses
Copy link
Member Author

@matthijseikelenboom What changes were you thinking of adding?

@0xWDG 0xWDG requested a review from tom-ludwig April 17, 2024 15:44
0xWDG
0xWDG previously approved these changes Apr 17, 2024
tom-ludwig
tom-ludwig previously approved these changes Apr 17, 2024
@austincondiff austincondiff enabled auto-merge (squash) April 20, 2024 15:15
@austincondiff austincondiff disabled auto-merge April 20, 2024 15:41
@austincondiff austincondiff merged commit ac3b4ca into main Apr 20, 2024
2 checks passed
@austincondiff austincondiff deleted the dep-injection branch April 20, 2024 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants