Skip to content

Instantly share code, notes, and snippets.

View serhatsezer's full-sized avatar
🎯
Focusing

Serhat Sezer serhatsezer

🎯
Focusing
View GitHub Profile
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'
name: MyApp
targetTemplates:
Module:
platform: iOS
type: framework
deploymentTarget: "10.0"
sources:
- path: Modules/${target_name}
group: MyApp/Modules
* 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/
import UIKit
protocol ViewModelType {
}
protocol Service {
func request(_ path: String, completion: @escaping ([String]) -> Void)
}
struct MainViewModel: ViewModelType {
import UIKit
protocol ViewModelType {
}
protocol Service {
func request(_ path: String, completion: @escaping ([String]) -> Void)
}
struct MainViewModel: ViewModelType {
// 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")
}
let gitHubProvider = MoyaProvider<GitHub>(plugins: [MoyaCacheablePlugin()])
extension GitHub: MoyaCacheable {
var cachePolicy: MoyaCacheablePolicy {
switch self {
case .userProfile:
return .returnCacheDataElseLoad
default:
return .reloadIgnoringLocalAndRemoteCacheData
// 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
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")!
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