Skip to content

Commit

Permalink
✨ Create 'TCA Service.xctemplate'
Browse files Browse the repository at this point in the history
  • Loading branch information
importre committed Feb 22, 2022
1 parent bf6664e commit 4fb464b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
Binary file added templates/TCA Service.xctemplate/TemplateIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions templates/TCA Service.xctemplate/TemplateInfo.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SupportsSwiftPackage</key>
<true/>
<key>Kind</key>
<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
<key>SortOrder</key>
<string>1</string>
<key>AllowedTypes</key>
<array>
<string>public.swift-source</string>
</array>
<key>Platforms</key>
<array />
<key>DefaultCompletionName</key>
<string>YourService</string>
</dict>
</plist>
53 changes: 53 additions & 0 deletions templates/TCA Service.xctemplate/___FILEBASENAME___Service.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//___FILEHEADER___

import ComposableArchitecture

protocol ___FILEBASENAMEASIDENTIFIER___ {
func greeting() -> Effect<String, Never>
}

final class ___FILEBASENAMEASIDENTIFIER___Live: ___FILEBASENAMEASIDENTIFIER___ {
func greeting() -> Effect<String, Never> {
.fireAndForget {
print("Hello")
}
}
}

extension ___FILEBASENAMEASIDENTIFIER___ where Self == ___FILEBASENAMEASIDENTIFIER___Live {
static var live: Self {
.init()
}
}

#if DEBUG
struct ___FILEBASENAMEASIDENTIFIER___Mock: ___FILEBASENAMEASIDENTIFIER___ {
let greetingEffect: Effect<String, Never>

func greeting() -> Effect<String, Never> { greetingEffect }
}

extension ___FILEBASENAMEASIDENTIFIER___ where Self == ___FILEBASENAMEASIDENTIFIER___Mock {
static func mock(
greeting: Effect<String, Never> = .none
) -> Self {
.init(
greetingEffect: greeting
)
}

static var noop: Self {
.init(
greetingEffect: .none
)
}

static var failing: Self {
.init(
greetingEffect: .fireAndForget {
fatalError("Not implemented yet")
}
)
}
}
#endif

0 comments on commit 4fb464b

Please sign in to comment.