Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rambler-digital-solutions/vipermcflurry
As tasty as McFlurry is
https://github.com/rambler-digital-solutions/vipermcflurry
Last synced: 5 days ago
JSON representation
As tasty as McFlurry is
- Host: GitHub
- URL: https://github.com/rambler-digital-solutions/vipermcflurry
- Owner: rambler-digital-solutions
- License: mit
- Created: 2015-11-10T14:14:41.000Z (about 9 years ago)
- Default Branch: develop
- Last Pushed: 2023-09-04T11:27:12.000Z (about 1 year ago)
- Last Synced: 2024-10-20T00:46:37.666Z (26 days ago)
- Language: Objective-C
- Homepage:
- Size: 1.2 MB
- Stars: 171
- Watchers: 36
- Forks: 43
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
### Overview
[![Pod version](https://badge.fury.io/co/ViperMcFlurry.svg)](https://badge.fury.io/co/ViperMcFlurry)
**VIPER McFlurry** is a modern framework for implementing [VIPER architecture](https://github.com/rambler-digital-solutions/The-Book-of-VIPER) in iOS application. It offers several tools and components that help either start new projects with VIPER or move from MVC.
![McFlurry](http://67.media.tumblr.com/36413ae65aa3f97fbce9ec53b21aa0ef/tumblr_oa2wlngg6u1r8u8uko1_500.jpg)
### Key Features
- The framework itself pushes you to implement a **proper VIPER architecture**,
- It provides an extremely nice and easy way to implement **intermodule data transfer**,
- Used in [default Generamba template](https://github.com/rambler-digital-solutions/generamba-catalog/tree/master/rviper_controller).### Usage
> This example works only for Module with `UIViewController` as View. However, it's possible to use this approach even with `UIView` and `UITableViewCell` acting as View.
- Create Module input protocol for target module inherited from ``RamblerViperModuleInput``:
```objective-c
@protocol SomeModuleInput- (void)moduleConfigurationMethod;
@end
```- Make Presenter of target module conform to this protocol.
- Inject Presenter as moduleInput property of the view. You can skip this step if presenter is a view property with name "output".
- Add Segue from source module ViewController to target module ViewController.
- Inject Source ViewController into Source Router as property "transition handler".
- In Router method call transition handler to open target module with configuration during segue.```objective-c
[[self.transitionHandler openModuleUsingSegue:SegueIdentifier]
thenChainUsingBlock:^id(id moduleInput) {
[moduleInput moduleConfigurationMethod];
return nil;
}];```
#### Working with Module output
- Create Module output protocol for target module inherited from ``RamblerViperModuleOutput``:
```objective-c
@protocol SomeModuleOutput- (void)moduleConfigurationMethod;
@end
```
- Make source module presenter to conform to this protocol.
- Add to target module presenter method:```objective-c
- (void)setModuleOutput:(id)moduleOutput;
```- Return source module presenter from configuration block in router:
```objective-c
[[self.transitionHandler openModuleUsingSegue:SegueIdentifier]
thenChainUsingBlock:^id(id moduleInput) {
[moduleInput moduleConfigurationMethod];
return sourceRouterPresenter; // Return of module output
}];```
#### Working with Module Factory
Module factory can be replaced with segues for most cases. Except you need to create complex module or nontrivial module instantiation logic.
- Use ```RamblerViperModuleFactory``` object as module fabric with Typhoon.
- Set definition Initializer to ```initWithViewControllerLoader:andViewControllerIdentifier:```
- First parameter is the object which loads the view controller, e.g. UIStoryboard or TyphoonNibLoader instance,
- Second parameter is view controller's identifier, e.g. RestorationID or NibName of ViewController.
- Typhoon will initialize module from ViewController.
- Inject this Factory into router.
- Call Transition Handler's method ``- openModuleUsingFactory:withTransitionBlock:``.
- Second block is place where transition from one to another viewController/transitionHandler should be performed:
```objective-c
[[self.transitionHandler openModuleUsingFactory:self.betaModuleFactory
withTransitionBlock:^(id sourceModuleTransitionHandler,
id destinationModuleTransitionHandler) {UIViewController *sourceViewController = (id) sourceModuleTransitionHandler;
UIViewController *destinationViewController = (id) destinationModuleTransitionHandler;[sourceViewController.navigationController pushViewController:destinationViewController
animated:YES];}] thenChainUsingBlock:^id(id moduleInput) {
[moduleInput configureWithExampleString:exampleString];
return nil;
}];
```
- In example above one module is pushed to navigation stack of another module.
- Modules are linked with intermodule data transfer block.### Installation
Add to podfile
```ruby
pod "ViperMcFlurry"
```### License
MIT
## Authors
**Rambler&Co** team:
- Andrey Zarembo-Godzyatsky / [email protected]
- Valery Popov / [email protected]
- Egor Tolstoy / [email protected]