Skip to content

Instantly share code, notes, and snippets.

Decision tree
I want to create one Observable
Produces a specific element: just
After a delay: timer
Pull elements from a sequence: from
Generate an element repeatedly: repeatElement
Custom logic exists: create
Generated on every subscription: deferred
Every once in a while, an element is emitted: interval
@tuannv19
tuannv19 / AlamofireRouterExample_Extended.swift
Created February 24, 2017 16:26 — forked from initFabian/AlamofireRouterExample_Extended.swift
An Alamofire router example used in a post, https://chaione.com/blog/rethinking-routers-swift-protocol-oriented-programming-part-1, to show how a router with multiple paths would look like.
// Router.swift
import Alamofire
enum Router: URLRequestConvertible {
static let baseURLString = "https://private-85a46-routable.apiary-mock.com/"
case readUsers
case createUser(parameters: Parameters)
@tuannv19
tuannv19 / RoutersProtocol.swift
Created February 24, 2017 16:05 — forked from initFabian/RoutersProtocol.swift
Complete basic router version of RoutesProtocol.swift that contains all the code along with comments.
//
// RoutesProtocol.swift
// RoutableApp
//
// Created by Fabian Buentello on 11/29/16.
// Copyright © 2016 ChaiOne. All rights reserved.
//
import Alamofire