Skip to content

Commit

Permalink
♻️ Refactor Input and Output as typealias. Added default implementati…
Browse files Browse the repository at this point in the history
…on for input()/output()
  • Loading branch information
usatie committed Apr 20, 2019
1 parent 940e50d commit f1023c5
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,29 @@ import AppCore
public final class ___FILEBASENAME___: UIViewController, Instantiatable, Injectable, Interactable {

// MARK: - Mew.Instantiatable
public struct Input {
let <#name#> = <#value#>
}
typealias Input = <#value#>
public typealias Environment = EnvironmentProvider
public var environment: Environment

// MARK: - Mew.Injectable
public func input(_ input: Input) {
<#code#>
private var input: Input {
didSet { updateUI() }
}

// MARK: - Mew.Interactable
public struct Output {
let <#name#> = <#value#>

func input(_ input: Input) {
self.input = input
}
public func output(_ handler: ((Output) -> Void)?) {
<#code#>

// MARK: - Mew.Emittable
typealias Output = <#value#>
private var handler: ((Output) -> Void)?
func output(_ handler: ((Output) -> Void)?) {
self.handler = handler
}

public init(with input: Input, environment: Environment) {
self.environment = environment
self.input = input
super.init(nibName: nil, bundle: Bundle(for: type(of: self)))
}

Expand Down
13 changes: 8 additions & 5 deletions PublicViewController.xctemplate/ViewController+Injectable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ import AppCore
public final class ___FILEBASENAME___: UIViewController, Instantiatable, Injectable {

// MARK: - Mew.Instantiatable
public struct Input {
let <#name#> = <#value#>
}
typealias Input = <#value#>
public typealias Environment = EnvironmentProvider
public var environment: Environment

// MARK: - Mew.Injectable
public func input(_ input: Input) {
<#code#>
private var input: Input {
didSet { updateUI() }
}

func input(_ input: Input) {
self.input = input
}

public init(with input: Input, environment: Environment) {
self.environment = environment
self.input = input
super.init(nibName: nil, bundle: Bundle(for: type(of: self)))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@ import AppCore
public final class ___FILEBASENAME___: UIViewController, Instantiatable, Interactable {

// MARK: - Mew.Instantiatable
public struct Input {
let <#name#> = <#value#>
}
typealias Input = <#value#>
public typealias Environment = EnvironmentProvider
public var environment: Environment

// MARK: - Mew.Interactable
public struct Output {
let <#name#> = <#value#>
}
public func output(_ handler: ((Output) -> Void)?) {
<#code#>
// MARK: - Mew.Emittable
typealias Output = <#value#>
private var handler: ((Output) -> Void)?
func output(_ handler: ((Output) -> Void)?) {
self.handler = handler
}

public init(with input: Input, environment: Environment) {
Expand Down
4 changes: 1 addition & 3 deletions PublicViewController.xctemplate/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import AppCore
public final class ___FILEBASENAME___: UIViewController, Instantiatable {

// MARK: - Mew.Instantiatable
public struct Input {
let <#name#> = <#value#>
}
typealias Input = <#value#>
public typealias Environment = EnvironmentProvider
public var environment: Environment

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,29 @@ import AppCore
final class ___FILEBASENAME___: UIViewController, Instantiatable, Injectable, Interactable {

// MARK: - Mew.Instantiatable
struct Input {
let <#name#> = <#value#>
}
typealias Input = <#value#>
typealias Environment = EnvironmentProvider
var environment: Environment

// MARK: - Mew.Injectable
private var input: Input {
didSet { updateUI() }
}

func input(_ input: Input) {
<#code#>
self.input = input
}

// MARK: - Mew.Interactable
struct Output {
let <#name#> = <#value#>
}
// MARK: - Mew.Emittable
typealias Output = <#value#>
private var handler: ((Output) -> Void)?
func output(_ handler: ((Output) -> Void)?) {
<#code#>
self.handler = handler
}

init(with input: Input, environment: Environment) {
self.environment = environment
self.input = input
super.init(nibName: nil, bundle: Bundle(for: type(of: self)))
}

Expand Down
11 changes: 7 additions & 4 deletions ViewController.xctemplate/ViewController+Injectable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ import AppCore
final class ___FILEBASENAME___: UIViewController, Instantiatable, Injectable {

// MARK: - Mew.Instantiatable
struct Input {
let <#name#> = <#value#>
}
typealias Input = <#value#>
typealias Environment = EnvironmentProvider
var environment: Environment

// MARK: - Mew.Injectable
private var input: Input {
didSet { updateUI() }
}

func input(_ input: Input) {
<#code#>
self.input = input
}

init(with input: Input, environment: Environment) {
self.environment = environment
self.input = input
super.init(nibName: nil, bundle: Bundle(for: type(of: self)))
}

Expand Down
13 changes: 5 additions & 8 deletions ViewController.xctemplate/ViewController+Interactable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@ import AppCore
final class ___FILEBASENAME___: UIViewController, Instantiatable, Interactable {

// MARK: - Mew.Instantiatable
struct Input {
let <#name#> = <#value#>
}
typealias Input = <#value#>
typealias Environment = EnvironmentProvider
var environment: Environment

// MARK: - Mew.Interactable
struct Output {
let <#name#> = <#value#>
}
// MARK: - Mew.Emittable
typealias Output = <#value#>
private var handler: ((Output) -> Void)?
func output(_ handler: ((Output) -> Void)?) {
<#code#>
self.handler = handler
}

init(with input: Input, environment: Environment) {
Expand Down
4 changes: 1 addition & 3 deletions ViewController.xctemplate/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import AppCore
final class ___FILEBASENAME___: UIViewController, Instantiatable {

// MARK: - Mew.Instantiatable
struct Input {
let <#name#> = <#value#>
}
typealias Input = <#value#>
typealias Environment = EnvironmentProvider
var environment: Environment

Expand Down

0 comments on commit f1023c5

Please sign in to comment.