This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {readFile} from 'fs' | |
import aws from 'aws-sdk' | |
import Promise from 'bluebird' | |
import cors from 'cors' | |
import express from 'express' | |
import formidable from 'formidable' | |
import gm from 'gm' | |
import {today} from '../../common/src/date' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: MyApp | |
targetTemplates: | |
Module: | |
platform: iOS | |
type: framework | |
deploymentTarget: "10.0" | |
sources: | |
- path: Modules/${target_name} | |
group: MyApp/Modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* https://tech.just-eat.com/2019/12/18/modular-ios-architecture-just-eat/ | |
* https://medium.com/flawless-app-stories/a-modular-architecture-in-swift-aafd9026aa99 | |
* https://blog.prototypr.io/architecting-ios-development-at-zomato-cf894a7fa5e3 | |
* https://tech.olx.com/modular-architecture-in-ios-c1a1e3bff8e9 | |
* https://benoitpasquier.com/how-build-modular-architecture-ios/ | |
* https://github.com/kudoleh/iOS-Modular-Architecture | |
* https://medium.com/freelancer-engineering/modular-architecture-on-ios-and-how-i-decreased-build-time-by-50-23c7666c6d2f | |
* https://engineering.depop.com/scaling-up-an-ios-app-with-modularisation-8cd280d6b2b8 | |
* https://academy.realm.io/posts/modular-ios-apps/ | |
* https://eng.uber.com/uber-freight-app-architecture-design/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
protocol ViewModelType { | |
} | |
protocol Service { | |
func request(_ path: String, completion: @escaping ([String]) -> Void) | |
} | |
struct MainViewModel: ViewModelType { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
protocol ViewModelType { | |
} | |
protocol Service { | |
func request(_ path: String, completion: @escaping ([String]) -> Void) | |
} | |
struct MainViewModel: ViewModelType { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ViewController.swift | |
func call(user: String) { | |
gitHubProvider.request(.userProfile(user)) { (result) in | |
switch result { | |
case .success(let data): | |
if let jsonData = try? data.mapJSON() { | |
print(jsonData) | |
} else { | |
print("error parsing to JSON") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let gitHubProvider = MoyaProvider<GitHub>(plugins: [MoyaCacheablePlugin()]) | |
extension GitHub: MoyaCacheable { | |
var cachePolicy: MoyaCacheablePolicy { | |
switch self { | |
case .userProfile: | |
return .returnCacheDataElseLoad | |
default: | |
return .reloadIgnoringLocalAndRemoteCacheData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MoyaCacheablePlugin.swift | |
final class MoyaCacheablePlugin: PluginType { | |
func prepare(_ request: URLRequest, target: TargetType) -> URLRequest { | |
if let moyaCachableProtocol = target as? MoyaCacheable { | |
var cachableRequest = request | |
cachableRequest.cachePolicy = moyaCachableProtocol.cachePolicy | |
return cachableRequest | |
} | |
return request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct User: Codable { | |
let userId: Int | |
let id: Int | |
let title: String | |
let completed: Bool | |
} | |
private func makeRequest() { | |
let url = URL(string: "https://jsonplaceholder.typicode.com/todos/1")! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let MEMORY_CAPACITY = 4 * 1024 * 1024 | |
let DISK_CAPACITY = 20 * 1024 * 1024 | |
let cache = URLCache(memoryCapacity: MEMORY_CAPACITY, diskCapacity: DISK_CAPACITY, diskPath: nil) | |
URLCache.shared = cache |
NewerOlder