(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
For faster connection speed and more flexibility.
/Applications/Xcode.app/Contents/MacOS/Xcode
// Copyright (c) 2019, SeatGeek, Inc | |
// All rights reserved. | |
// | |
// Redistribution and use in source and binary forms, with or without | |
// modification, are permitted provided that the following conditions are met: | |
// | |
// * Redistributions of source code must retain the above copyright notice, this | |
// list of conditions and the following disclaimer. | |
// | |
// * Redistributions in binary form must reproduce the above copyright notice, |
// | |
// CAAnimation+BlockCallback.swift | |
// | |
import UIKit | |
// | |
// Modified from http://onedayitwillmake.com/blog/2016/06/caanimation-completion-callback-block/ | |
// Updated for Swift 4 syntax | |
// All credit to the original author (Mario Gonzalez) |
//: [Previous](@previous) | |
import Foundation | |
import SwiftUI | |
import Combine | |
//: Current Value Subject is a value, a publisher and a subscriber all in one | |
let currentValueSubject = CurrentValueSubject<Bool, Never>(true) | |
print(currentValueSubject.value) |
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
HStack { | |
Text("Hello") | |
.padding() | |
.background(.blue) | |
.overlay { | |
Color.yellow |
extension Color { | |
/// Return a random color | |
static var random: Color { | |
return Color( | |
red: .random(in: 0...1), | |
green: .random(in: 0...1), | |
blue: .random(in: 0...1) | |
) | |
} | |
} |
- In almost all cases where you type `@ObservedObject`, you really want `@StateObject`. | |
If you need to support iOS 13, use `@State` on parent and pass value into child with `@ObservedObject` to simulate `@StateObject`. | |
Pass arguments to that model in `onAppear`. Example: https://github.com/ra1028/SwiftUI-Hooks/blob/main/Sources/Hooks/HookScope.swift#L39-L41 | |
``` | |
.onAppear { | |
model.onAppear(userTag: userTag) | |
} | |
.onDisappear { | |
model.onDisappear() |
import SwiftUI | |
extension View { | |
public func discover<T: UIView>( | |
where predicate: @escaping (T) -> Bool = { _ in true }, | |
_ closure: @escaping (T) -> Void | |
) -> some View { | |
overlay( | |
DiscoveryView(predicate: predicate, setup: closure) | |
.frame(width: 0, height: 0) |
#!/opt/homebrew/bin/python3 | |
import re | |
import glob | |
import os | |
import graphviz | |
################################################################################## | |
######### USAGE ######### |