Git Product home page Git Product logo

viperbuilder's Introduction

VIPERBuilder

Build Status codecov.io CII Best Practices

Scaffolding for building apps in a clean way with VIPER architecture.

VIPER inherently has a few problems:

  • Boilerplate
  • Potential retain cycles due to management of many classes
  • Cognitive overhead of setup

This framework aims to address those problems by providing a set of base classes to divide your app's functionality and builder object to manage the connections.

Installation

Cocoapod

Add pod VIPERBuilder to your Podfile

Run pod install

Usage

  1. Create subclasses of VIPERInteractor, VIPERPresenter and VIPERRouter as needed

  2. Create a strong reference to an instance of VIPERBuilder with the new subclasses specified. Lazy loading in Swift will ensure that the builder object is available as soon as it is called

    lazy var viperBuilder: VIPERBuilder<NewInteractor, NewPresenter, NewRouter> = { return VIPERBuilder(controller: self) }()

Note: If not all classes are needed for the implementation passing the superclass to the Builder object is supported

For a more detailed implementation, please check out the demo project included in this repo

Code Separation

This framework provides three base classes for the three main parts of VIPER: Interactor, Presenter, Router. Each class should contain certain pieces of code and has references to other classes for specific reasons, however these can be extended through subclassing.


Interactor

Purpose
  • User interaction (directly and through delegation from other classes)
  • Data fetching/mutation
Reference usages
  • Presenter: should be used to update view after fetching or mutating data
  • Router: Used for navigation based on actions taken

Presenter

Purpose
  • Configuring view/view model (entity objects)
  • Presenting modals/loading screens
Reference usages
  • Controller: Presenting modals/error messages
  • Interactor: Can be used as a delegate for any actions from views

Router

Purpose
  • Navigation (pushing views onto UINavigationController's stack)
Reference usages
  • Navigation controller: Used for pushing screens

viperbuilder's People

Contributors

jacobvanorder avatar macdoum1 avatar waltflanagan 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

Watchers

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

viperbuilder's Issues

How to write unit testing with VIPERBuilder

I used to use VIPER with Presenter & Interactor & Router variables in the UIViewController but I after awhile I found VIPERBuilder saves the time and make the code more readble, but I have a problem when write unit testing for VIPER component with VIPERBuilder, because the viperBuilder in the next code depends on the concrete implementation not the abstract, but in the old way the variable was protocols which you can mock easily.

lazy var viperBuilder:
       VIPERBuilder<DemoInteractor, DemoPresenter, DemoRouter> = {
       return VIPERBuilder(controller: self)
   }()

I already made some work around to write the unit testing but this is not straight forward.

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.