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 Foundation | |
import Combine | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
//PlaygroundPage.current.finishExecution() | |
let subject = PassthroughSubject<Int, Never>() | |
/// Proves that even strong references inside a cancellable's `receiveCompletion` or `receiveValue` |
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
// | |
// AmplifyService.swift | |
// AmplifyAuthSample | |
// | |
// Created by Schmelter, Tim on 8/13/20. | |
// Copyright © 2020 Amazon Web Services. All rights reserved. | |
// | |
import Amplify | |
import AmplifyPlugins |
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 Combine | |
import Foundation | |
/// A Subscription that buffers values until the receiver demands them. Useful for | |
/// subscribing to Subjects that produce values irrespective of whether there is a | |
/// downstream subscriber (e.g., a PassthroughSubject used by an imperative process | |
/// to deliver a stream of events. A BufferingSubscription can be used to request | |
/// unlimited demand from the upstream publisher, and buffer the values until the | |
/// downstream subscriber demands them. | |
@available(iOS 13.0, *) |
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
// Copy this into an Xcode Playground | |
import Foundation | |
import Combine | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
let odds = PassthroughSubject<Int, Never>() | |
let evens = PassthroughSubject<Int, Never>() |
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 Foundation | |
protocol TestClassFactory { | |
static func make() -> TestClass | |
} | |
protocol TestClass { | |
var testValue: String { get set } | |
} |
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 Person { | |
name: string; | |
friends: Array<Person>; | |
constructor(name: string) { | |
this.name = name; | |
this.friends = []; | |
} | |
addFriends(friends: Array<Person>) { |
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
// @flow | |
function doAsyncWork(shouldSucceed: boolean): Promise<number> { | |
let p = new Promise(function asyncWorker(resolve, reject) { | |
setTimeout(function() { | |
if (shouldSucceed) { | |
resolve(42); | |
} else { | |
let error = new Error("rejected"); | |
reject(error); |
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
/* @flow */ | |
type EnumName = string; | |
type EnumProperties = {[key: any]: any}; | |
/// An abstract class that defines semantics for typesafe `enum` style implementations in JavaScript. | |
/// Relies on ES6 extensions to support static properties, and is therefore not suitable for all | |
/// projects. | |
/// | |
/// Usage: |
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 Foundation | |
class Node<T: Comparable> { | |
let value: T | |
var left: Node? | |
var right: Node? | |
init(value: T, left: Node? = nil, right: Node? = nil) { | |
self.value = value | |
self.left = left |
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
#!/usr/bin/env ruby | |
class AppShell | |
require "logger" | |
require "optparse" | |
@@BANNER = "A shell with app boilerplate & option parsing, suitable for subclassing" | |
@@VERSION = [0, 0, 1] | |
LOG_LEVELS = [ Logger::WARN, Logger::INFO, Logger::DEBUG ] |
NewerOlder