Skip to content

Commit

Permalink
Added more deprecations (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
KazaiMazai authored Sep 3, 2024
1 parent d992664 commit f4182a4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Sources/Puredux/Store/Core/CoreStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Dispatch
import Foundation

public typealias Dispatch<Action> = (_ action: Action) -> Void
@available(*, deprecated, message: "Will be removed in 2.0")
public typealias Interceptor<Action> = (Action, @escaping Dispatch<Action>) -> Void

typealias StoreID = UUID
Expand Down
4 changes: 3 additions & 1 deletion Sources/Puredux/Store/Deprecated/RootStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

import Foundation

@available(*, deprecated, message: "Will be removed in 2.0.")
public enum StoreQueue {
case main
case global(qos: DispatchQoS = .userInteractive)
}

public typealias Reducer<State, Action> = (inout State, Action) -> Void

@available(*, deprecated, message: "Will be removed in 2.0. Consider migrating to StateStore")
public final class RootStore<State, Action> {
private let internalStore: CoreStore<State, Action>

Expand All @@ -28,7 +30,7 @@ public final class RootStore<State, Action> {
/// RootStore is a factory for light-weight stores that are created as proxies for the internal store.
///
///
@available(*, deprecated, message: "Will be removed in 2.0. Consider migrating to StoreFactory")
@available(*, deprecated, message: "Will be removed in 2.0. Consider migrating to StateStore")
public init(queue: StoreQueue = .global(qos: .userInteractive),
initialState: State,
reducer: @escaping Reducer<State, Action>) {
Expand Down
38 changes: 16 additions & 22 deletions Sources/Puredux/Store/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,14 @@

import Foundation

public extension Store {

/// Closure that handles Store's dispatching Actions
///
typealias Dispatch = (_ action: Action) -> Void

/// Closure that takes Observer as a parameter and handles Store's subscribtions
///
typealias Subscribe = (_ observer: Observer<State>) -> Void
}
public typealias Dispatch<Action> = (_ action: Action) -> Void

public typealias Subscribe<S> = (_ observer: Observer<S>) -> Void

public struct Store<State, Action> {
let dispatchHandler: Dispatch
private let subscribeHandler: Subscribe
let dispatchHandler: Dispatch<Action>
private let subscribeHandler: Subscribe<State>
}

public extension Store {
Expand All @@ -45,9 +39,9 @@ public extension Store {
/// For all other cases, RootStore or StoreFactory should be used to create viable light-weight Store.
///
///
@available(*, deprecated, renamed: "Store.mockStore(dispatch:subscribe:)", message: "Will be removed in the next major release")
init(dispatch: @escaping Dispatch,
subscribe: @escaping Subscribe) {
@available(*, deprecated, renamed: "Store.mockStore(dispatch:subscribe:)", message: "Will be removed in 2.0")
init(dispatch: @escaping Dispatch<Action>,
subscribe: @escaping Subscribe<State>) {
self.init(dispatcher: dispatch, subscribe: subscribe)
}

Expand All @@ -62,9 +56,9 @@ public extension Store {
///
/// For all other cases, RootStore or StoreFactory should be used to create viable light-weight Store.
///
///
static func mockStore(dispatch: @escaping Dispatch,
subscribe: @escaping Subscribe) -> Store<State, Action> {
@available(*, deprecated, renamed: "Store.mockStore(dispatch:subscribe:)", message: "Will be removed in 2.0")
static func mockStore(dispatch: @escaping Dispatch<Action>,
subscribe: @escaping Subscribe<State>) -> Store<State, Action> {

Store(dispatcher: dispatch, subscribe: subscribe)
}
Expand All @@ -89,7 +83,7 @@ public extension Store {
/// All dispatched Actions and subscribtions are forwarded to the root store.
/// Store is thread safe. Actions can be dispatched from any thread. Can be subscribed from any thread.
///
@available(*, deprecated, message: "Will be removed in 2.0. Consider migrating to scope(...)")
@available(*, deprecated, message: "Will be removed in 2.0. Consider migrating to map(...)")
func proxy<LocalState>(_ toLocalState: @escaping (State) -> LocalState) -> Store<LocalState, Action> {
map(toLocalState)
}
Expand All @@ -107,7 +101,7 @@ public extension Store {
/// When the result local state is nill, subscribers are not triggered.
///
///
@available(*, deprecated, message: "Will be removed in 2.0")
@available(*, deprecated, message: "Will be removed in 2.0. Consider migrating to flatMap(...)")
func scope<LocalState>(toOptional localState: @escaping (State) -> LocalState?) -> Store<LocalState, Action> {
compactMap(localState)
}
Expand All @@ -120,15 +114,15 @@ public extension Store {
/// All dispatched Actions and subscribtions are forwarded to the root store.
/// Store is thread safe. Actions can be dispatched from any thread. Can be subscribed from any thread.
/// When the result local state is nill, subscribers are not triggered.
///
@available(*, deprecated, message: "Will be removed in 2.0. Consider migrating to map(...)")
func scope<LocalState>(to localState: @escaping (State) -> LocalState) -> Store<LocalState, Action> {
map(localState)
}
}

extension Store {
init(dispatcher: @escaping Dispatch,
subscribe: @escaping Subscribe) {
init(dispatcher: @escaping Dispatch<Action>,
subscribe: @escaping Subscribe<State>) {

dispatchHandler = dispatcher
subscribeHandler = subscribe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import SwiftUI


@available(*, deprecated, message: "Will be removed in 2.0. Check ViewWithStore migration guide")
public struct StoreProvidingView<AppState, Aciton, Content: View>: View {
private let rootStore: RootEnvStore<AppState, Aciton>
private let content: () -> Content
Expand Down

0 comments on commit f4182a4

Please sign in to comment.