Skip to content

Instantly share code, notes, and snippets.

@funway
funway / TimerTest.swift
Created Aug 6, 2020
View with NSWindowDelegate, listens window events
View TimerTest.swift
import SwiftUI
struct TimerTest: View {
@State var date = Date()
@State var showSubView = false
var windowDelegate: MyWindowDelegate = MyWindowDelegate()
var body: some View {
ZStack{
if showSubView {
@funway
funway / TimerTest.swift
Created Aug 4, 2020
TimerPublisher conflict with NSWindow.willCloseNotification
View TimerTest.swift
import SwiftUI
struct TimerTest: View {
@State var showSubView = false
@State var date1 = Date()
@State var timer1 = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
weak var myWindow: NSWindow?
// In AppDelegate.swift, use "let contentView = TimerTest(myWindow: window)"
var body: some View {
@funway
funway / TimerTest.swift
Last active Aug 5, 2020
Test of TimerPublisher in SwiftUI
View TimerTest.swift
import SwiftUI
struct TimerTest: View {
@State var date = Date()
@State var showSubView = false
@State var timer: Timer?
@State var date1 = Date()
@State var timer1 = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
var body: some View {
@funway
funway / Laravel-Container.md
Last active Apr 20, 2020 — forked from davejamesmiller/Laravel-Container.md
Laravel's Dependency Injection Container in Depth 【中文翻译】
View Laravel-Container.md

深入理解Laravel容器

Laravel 是一个具有很强控制反转(IoC)与依赖注入(DI)能力的容器。不幸的是它的官方文档没有更详细的介绍这些用法,所以我决定自己做点试验并写些更详细的文档。下面所有的都是基于Laravel 5.4.26,不同版本可能有异。

依赖注入

我不会在这里介绍DI/IoC的原理,如果对依赖注入与控制反转不是很熟悉,你可以阅读这篇文章 What is Dependency Injection?

访问容器