You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
520 B
25 lines
520 B
//
|
|
// AutoSaveManager.swift
|
|
// Notes
|
|
//
|
|
// Created by Claude Code on 13/10/2025.
|
|
//
|
|
|
|
import Foundation
|
|
import Combine
|
|
|
|
class AutoSaveManager: ObservableObject {
|
|
private var timer: Timer?
|
|
private let idleTimeBeforeSaving: TimeInterval = 2.0
|
|
|
|
func requestSave(action: @escaping () -> Void) {
|
|
timer?.invalidate()
|
|
timer = Timer.scheduledTimer(withTimeInterval: idleTimeBeforeSaving, repeats: false) { _ in
|
|
action()
|
|
}
|
|
}
|
|
|
|
deinit {
|
|
timer?.invalidate()
|
|
}
|
|
}
|
|
|