You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 19, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: _posts/2020-03-19-dependecy-injection-swift.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
---
2
2
layout: post
3
-
title: "How to: create your SUPER simple dependency injector framework in Swift"
4
-
description: "There are a lot of dependency injection framework in the open source swift world with really cool features like object graph, persistence etc. But what if all you need is a lightweight dependencies container? In this post I will show you how to create it by leveraging the Metatype Type, the Hashable protocol and the Equatable protocol."
3
+
title: "How to: create your SUPER simple dependency injector container in Swift"
4
+
description: "There are a lot of dependency injection framework in the open source swift world with really cool features like object graph, persistence etc. But what if all you need is a lightweight dependencies container? In this post I will show you how to create it by leveraging the Metatype Type, Generics, the Hashable protocol and the Equatable protocol."
5
5
date: 2020-03-19
6
-
image: /assets/images/posts/XXXXXXXXXXXXX
6
+
image: /assets/images/posts/dp-container.jpg
7
7
tags: [swift, ios, apple, mobile application development]
8
8
comments: true
9
9
math: false
@@ -12,7 +12,7 @@ seo:
12
12
authors: [fabrizio_duroni]
13
13
---
14
14
15
-
*There are a lot of dependency injection framework in the open source swift world with really cool features like object graph, persistence etc. But what if all you need is a lightweight dependencies container? In this post I will show you how to create it by leveraging the Metatype Type and the Hashable protocol and the Equatable protocol.*
15
+
*There are a lot of dependency injection framework in the open source swift world with really cool features like object graph, persistence etc. But what if all you need is a lightweight dependencies container? In this post I will show you how to create it by leveraging the Metatype Type, Generics, the Hashable protocol and the Equatable protocol.*
16
16
17
17
---
18
18
@@ -27,7 +27,7 @@ The main one stores in the field `dependecies` a dictionary of all the dependenc
27
27
28
28
*`resolve<T>(type: T.Type, name: String? = nil) -> T?`, that lets you get an instance previously registered. This method accept the same first two parameter of the previous method. It will return null if none of the registered instance has a combination of `type` and `name` as the one received as parameters.
29
29
30
-
This is the implementation of `DependeciesContainer`.
30
+
As you can see both method extensively uses generics in order to be able to accept any possible class or protocol you may want to use. This is the implementation of `DependeciesContainer`.
0 commit comments