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
# Source https://github.com/PaulTaykalo/swift-scripts/blob/master/unused.rb | |
class String | |
def black; "\e[30m#{self}\e[0m" end | |
def red; "\e[31m#{self}\e[0m" end | |
def green; "\e[32m#{self}\e[0m" end | |
def yellow; "\e[33m#{self}\e[0m" end | |
def blue; "\e[34m#{self}\e[0m" end | |
def magenta; "\e[35m#{self}\e[0m" end | |
def cyan; "\e[36m#{self}\e[0m" end | |
def gray; "\e[37m#{self}\e[0m" end |
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
// MuslimApp AppLaucherViewController.swift | |
// DidSelectCellForRowAt indexPath: IndexPath | |
let subApp = items[indexPath.row] | |
let vc = subApp.starter | |
navigationController.pushViewController(vc, animated: true) |
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
// MuslimApp Application.swift | |
import MuslimNote | |
let subApplication: [SubApplication] = [ | |
MuslimNote.Application() | |
] |
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
// MuslimNote | |
// Application.swift | |
import SubApplication | |
public class Application: SubApplication { | |
let name = "Muslim Note" | |
let thumbnail = UIImage(named: "muslim_note_thumnail") | |
let starter: UIViewController | |
init() { | |
let vc = HomeController( | |
nibName: "HomeController" |
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
public protocol SubApplication { | |
var name: String { get } | |
var thumbnail: UIImage? { get } | |
var starter: UIViewController { get } | |
} |
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
/// MuslimApp | |
// AppLaucherViewController.swift | |
import SubApplication | |
class AppLaucherViewController: UITableViewController { | |
private var items: [SubApplication] = [] | |
convenience init(items: [SubApplication]) { | |
self.init() |
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
class WhateverUseCase { | |
... | |
let store: Store // I don't need specify any type | |
func performOperation() { | |
/// Car | |
store.fetch(Car.self, with: [.color(.red), .year(Date())]) | |
.success { cars in | |
// Do logic | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<style> | |
.main-button { | |
background-color: white; | |
color: black; | |
border: 2px solid #4CAF50; |
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
// Setelah print "Fetch Error ..." maka subscription -> onCompleted -> isDisposed (dan tidak bisa fetchProduct lagi) | |
Network.fetchProduct() // Return Observable<[Product]> | |
.subscribe(onNext: { value in | |
print("Product is \(value)") | |
}, onError: { error in | |
print("Fetch Error \(error)") | |
}) | |
.diposed(by: bag) |
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 user: PublishSubject<User>() | |
let cart = user.startWith( ... ) // I provide a starter value for sequence | |
.flatMapLatest { user -> Observable<Cart> in | |
return Observable.just(user.cart) | |
} | |
.map { | |
... // Do some logic here | |
} | |
// Updating user for other observer |