Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii committed Mar 4, 2024
1 parent 35772f6 commit 689029b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Sources/Verge/Library/EventEmitter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Foundation
import os
import DequeModule

public final class EventEmitterCancellable: Hashable, CancellableType {
public final class EventEmitterCancellable: Hashable, Cancellable, @unchecked Sendable {

public static func == (lhs: EventEmitterCancellable, rhs: EventEmitterCancellable) -> Bool {
lhs === rhs
Expand All @@ -46,7 +46,7 @@ public final class EventEmitterCancellable: Hashable, CancellableType {
}
}

protocol EventEmitterType: AnyObject {
protocol EventEmitterType: AnyObject, Sendable {
func removeEventHandler(_ token: EventEmitterCancellable)
}

Expand Down
12 changes: 11 additions & 1 deletion Sources/Verge/Library/StoreSubscription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Combine
A subscription that is compatible with Combine’s Cancellable.
You can manage asynchronous tasks either call the ``cancel()`` to halt the subscription, or allow it to terminate upon instance deallocation, and by implementing the ``storeWhileSourceActive()`` technique, the subscription’s active status is maintained until the source store is released.
*/
public final class StoreSubscription: Hashable, Cancellable {
public final class StoreSubscription: Hashable, Cancellable, @unchecked Sendable {

public static func == (lhs: StoreSubscription, rhs: StoreSubscription) -> Bool {
lhs === rhs
Expand All @@ -18,6 +18,8 @@ public final class StoreSubscription: Hashable, Cancellable {
private let wasCancelled = ManagedAtomic(false)

private let source: EventEmitterCancellable

// TODO: can't be sendable
private weak var storeCancellable: VergeAnyCancellable?
private var associatedStore: (any StoreType)?
private var associatedReferences: [AnyObject] = []
Expand All @@ -38,6 +40,14 @@ public final class StoreSubscription: Hashable, Cancellable {
associatedStore = nil
}

public func suspend() {

}

public func resume() {

}

func associate(store: some StoreType) -> StoreSubscription {
ensureAlive()
associatedStore = store
Expand Down

0 comments on commit 689029b

Please sign in to comment.