Skip to content

Instantly share code, notes, and snippets.

View SeRG1k17's full-sized avatar

Sergey Pugach SeRG1k17

  • Minsk
View GitHub Profile
protocol Vehicle {
var name: String { get }
associatedtype FuelType
func fillGasTank(with fuel: FuelType)
}
struct Car: Vehicle {
```swift
import Combine
extension Publisher {
func fromResult<T, E>() -> AnyPublisher<T, E>
where Self.Failure == Never, Self.Output == Result<T, E>, E: Error {
setFailureType(to: E.self)
.tryMap { (result: Self.Output) -> T in
switch result {
@SeRG1k17
SeRG1k17 / Publisher+Ext.swift
Created September 29, 2020 11:23
Swift combine StartWith
extension Publisher {
func unwrap() -> Publishers.CompactMap<Self, Self.Output> {
return compactMap({ $0 })
}
func startWith1(_ value: Self.Output) -> Publishers.Merge<AnyPublisher<Self.Output, Self.Failure>, Self> {
return Publishers.Merge(Just(value).setFailureType(to: Self.Failure.self).eraseToAnyPublisher(), self)
}
@SeRG1k17
SeRG1k17 / hamburger.swift
Last active June 22, 2018 13:30 — forked from chrislconover/hamburger.swift
Example of how to use presentation, animation & interaction controllers w/ custom segues to create a slide-in modal menu which partially covers presenting view.
// https://gist.github.com/MrAlek/3d1520ca2c5d981489e2
import UIKit
enum Direction {
case left, right, up, down
var pointVector: CGPoint {
switch self {
case .left: return CGPoint(x: -1, y: 0)
{
address = {
addressText = "toru\U0144ski";
apartment = "<null>";
cityId = 1;
floor = "<null>";
id = 0;
intercom = "<null>";
latitude = "53.13196290250359";
longitude = "18.30662839114666";