Skip to content
This repository was archived by the owner on Jan 30, 2021. It is now read-only.

Comments

Actionable Improvements#104

Closed
nevillco wants to merge 12 commits intomasterfrom
bugfix/nevillco/actionable
Closed

Actionable Improvements#104
nevillco wants to merge 12 commits intomasterfrom
bugfix/nevillco/actionable

Conversation

@nevillco
Copy link
Contributor

@nevillco nevillco commented May 22, 2018

In working on a client project, we have Services that require delegation and would benefit from Actionable. We soon realized:

  • The Services framework does not include Actionable
  • Even if it did, the existing implementation breaks for non-internal types

This PR:

  • Tweaks the Actionable template to use the access control of the implementing type
  • Moves "utility" functions into a new Actionable+Helpers.swifttemplate file for readability
  • Adds a Sourcery build phase to the Services target, and moves the template files (which are now shared between targets) to Services
  • Allows for nested Actionable types. Prior to this PR, the following code would cause Sourcery to generate non-compiling code:
class Foo {
    class Bar: Actionable {
        weak var delegate: Delegate?
        enum Action {
            case baz
        }
    }
}

Now, it generates:

// MARK: - Foo.Bar
internal protocol FooBarDelegate: class {

    func bar(_ component: Foo.Bar, didNotify action: Foo.Bar.Action)

}

internal extension Foo.Bar {

    typealias ActionType = Action
    typealias Delegate = FooBarDelegate

    func notify(_ action: ActionType) {
        delegate?.bar(self, didNotify: action)
    }

    func with(delegate: Delegate) -> Self {
        self.delegate = delegate
        return self
    }

}

@raizlabs-oss-bot
Copy link

raizlabs-oss-bot commented May 22, 2018

1 Warning
⚠️ Big PR
4 Messages
📖 Test Results
📖 Code Coverage: xcov
📖 Code Coverage: Slather
📖 Screenshots

Current coverage for Services.framework is 63.40%

Files changed - -
Actionable.swift 0.00% 💀

Current coverage for debug-PRODUCTNAME.app is 1.81%

Files changed - -
Actionable.swift 0.00% 💀
Actionable+AutoConformance.swift 0.00% 💀

Powered by xcov

Generated by 🚫 Danger

@heyltsjay
Copy link

@nevillco Agreed that we shouldn't duplicate the template files. I would be ok with them living in their Services home if you can pull off the generation. Or perhaps an alias can help.

…from PRODUCTNAME directory. Make Services version available to both targets and update build phase
@nevillco
Copy link
Contributor Author

@heyltsjay Done - template files are living in Services

delegate?.authCoordinator(self, didNotify: action)
}

func with(delegate: Delegate) -> Self {

Choose a reason for hiding this comment

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

@nevillco maybe a touch opinionated for the template?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair 👍

@nevillco
Copy link
Contributor Author

Closing in favor of #116

@nevillco nevillco closed this Feb 15, 2019
@nevillco nevillco deleted the bugfix/nevillco/actionable branch February 15, 2019 17:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants