Giter Club home page Giter Club logo

clean-swift-templates's Introduction

Clean-swift templates

This is a modification of Clean Swift Templates (http://clean-swift.com) made by HELM (www.helm.cat)

To learn more about Clean Swift and the VIP cycle, read:

http://clean-swift.com/clean-swift-ios-architecture

Changelog

This modification aims to create work-ready templates and snippets to achieve the maximum efficiency for people who are already familiar with them. Furthermore we added some extra features in order to attempt to solve some issues.

Here is a list of what is modified:

Added features:

  • Awesome snippet to create usecases
  • New data-passing method
  • Added Store Template

Snippet

alt text

New data-passing method

Previously to pass data we need to do something like this in the source Router:

let user = sourceViewController.output.selectedUser
destinationViewController.output.user = user

We think this is wrong because:

  1. We are not trying to output anything from the ViewController.
  2. We are assuming the output === Interactor and the architecture loses sense (no component should know about what kind of object its output/input is).
  3. We dont want the ViewController to know anything about Business model.
  4. We want the Interactor to handle this data but we don't want the ViewController to know anything about it.

So we added 2 new protocols on the router

protocol RouterDataSource: class {

}
protocol RouterDataDestination: class {

}
  • The RouterDataSource protocol is used to determine what business data has to be passed somewhere.
  • The RouterDataDestination protocol is used to determine what data has to be received and handled by this scene.

So following the example before we would add this in the source Router:

protocol UserListRouterDataSource: class {
    var selectedUser: User! { get }
}

protocol UserListRouterDataDestination: class {

}

And this in the destination:

protocol UserDetailRouterDataSource: class {

}

protocol UserDetailRouterDataDestination: class {
    var user: User! { get set }
}

As we added a dataSource object and a dataDestination object in the Router, we can now do this:

let user = dataSource.selectedUser
userDetailViewController.router.dataDestination.user = user

As previously mentioned we believe this handling should be done by the Interactor aswell but without the ViewController knowing it so we added the protocols there and changed the Configurator.swift in order to connect both protocols.

So the source Interactor would look like this:

protocol UserListDataSource {
    var selectedUser: User! { get }
}

protocol UserListDataDestination {

}

class UserListInteractor: UserListInteractorInput, UserListDataSource, UserListDataDestination {

And as you would assume, the destination Interactor looks like this:

protocol UserDetailDataSource {

}

protocol UserDetailDataDestination {
    var user: User! { get set }
}

class UserDetailInteractor: UserDetailInteractorInput, UserDetailDataSource, UserDetailDataDestination {

You can see a working example in the Example folder.

Installation

To install the Clean Swift Xcode HELM templates and snippets, run:

./configure
make install

To uninstall the Clean Swift Xcode templates and snippets, run:

make uninstall

To try the Example project you need carthage:

brew update
brew install carthage

Then run

./cartupdate.sh

In the project folder (/Example)

clean-swift-templates's People

Contributors

ambenpau avatar cruisediary avatar darkcl avatar mijail avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clean-swift-templates's Issues

Does it works properly with Xcode 9?

Can someone check and confirm? I'm getting for example autogenerated file like "MainListViewControllerViewController" which doesn't works properly.

Communication between scene

Hi,

If one scene need to trigger a method in another scene how will you do? Say for example, I have a webviewcontroller which is used to display contents like books/ pages etc and I have a full clean swift cycle for it, and I have js functions written in the view controller which can be triggered. Now I have a container view and I need to load the out put of a js function to this container from the webviewcontroller scene.

ie scene 2-->Viewcontroller-->On Button Click-->Invoke-->Scene1-->WebviewController-->Evaluatejs-->getOutPut-->giveit to -->Scene 2-->Interactor

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.