Skip to content

Instantly share code, notes, and snippets.

View ihamadfuad's full-sized avatar
🧑‍💻
Swifting with UI and server

Hamad Fuad ihamadfuad

🧑‍💻
Swifting with UI and server
View GitHub Profile
extension Notification.Name {
static let taskAddedNotification = Notification.Name("TaskAddedNotification")
}
struct ListenToNotificationChanges: View {
@State private var newTask: String?
var body: some View {
VStack {
@MihaelIsaev
MihaelIsaev / AwesomeWSPing.swift
Created July 4, 2022 21:23
AwesomeWS automatic ping implementation
class YourCustomWS: ClassicObserver, LifecycleHandler {
var pingTask: RepeatedTask?
var waitForPongAttempts: [WaiterForPongAttempt] = []
public required init (app: Application, key: String, path: String, exchangeMode: ExchangeMode) {
super.init(app: app, key: key, path: path, exchangeMode: exchangeMode)
pingTask = app.eventLoop.scheduleRepeatedTask(initialDelay: .seconds(5), delay: .seconds(5)) { [weak self] task in
guard let self = self else { return }
self.waitForPongAttempts.enumerated().forEach { i, object in
if object.attempt >= 2 {
@shayanbo
shayanbo / AsyncImage.swift
Last active July 6, 2023 09:42
Enhanced AsyncImage Sample
import SwiftUI
import CommonCrypto
struct AsyncImage<Content> : View where Content: View {
enum Error : Swift.Error {
case invalidData
}
private let url: URL
//
// ContentView.swift
// Emitter
//
// Created by localuser on 18.04.23.
//
import SwiftUI
import Combine
import Algorithms