Skip to content

Instantly share code, notes, and snippets.

View iSevenDays's full-sized avatar

Anton Sokolchenko iSevenDays

View GitHub Profile
@iSevenDays
iSevenDays / ViewModelClosable.swift
Last active October 12, 2021 10:40
SwiftUI create View Model that emits close action
import Foundation
import Combine
import SwiftUI
/// View Model closable protocol - conform to this protocol if your view model should emit close block to close the screen that uses this view model
public protocol ViewModelClosableProtocol {
var closeCancellable: AnyCancellable? { get set }
// when inheriting protocol, set @Published
// var shouldCloseView: Bool { get set }